[swift-users] Decode a JSON object of unknown format into a Dictionary with Decodable in Swift 4

David Hart david at hartbit.com
Fri Jun 23 03:34:05 CDT 2017


> On 23 Jun 2017, at 03:45, Jon Shier via swift-users <swift-users at swift.org> wrote:
> 
> 	I’m sorry, are you complaining about my use of Codable instead of more precisely referring to the JSON endcode/decode functionality based on it in Foundation, or are you honestly trying to say that said functionality was never intended to be a general purpose JSON solution? If it’s not actually intended to handle all JSON you should probably call it something else.

Hi Jon,

First of all, I'd like to point out that I've found your tone to be quite rude. Calling the design of Codable, that has gotten a lot of work from Apple and swift-evolution, as silly is insulting and can leave people hurt. If you have found it lacking, please say so: we're all here to discuss any feedback people have had with Swift. But please do so with respect for the people and the work behind it.

Now, concerning Codable, I find its name quite apt. It was never intended to be used a full JSON parser but as a strongly-typed Swift equivalent of Objective-C's NSCoding, which is nothing more than a framework for serializing and deserializing types into different file formats.

David.

> Jon
> 
>>> On Jun 22, 2017, at 9:42 PM, Greg Parker <gparker at apple.com> wrote:
>>> 
>>> 
>>> On Jun 22, 2017, at 6:00 PM, Jon Shier via swift-users <swift-users at swift.org> wrote:
>>> 
>>> 	My main concern here is that, as Swift’s official JSON parsing method, Codable should be able to handle any JSON representation and use and it doesn’t.
>> 
>> Is this true? Is Codable intended to be Swift's official JSON parsing system? Is Codable intended to be a general-purpose JSON parsing system? 
>> 
>> My understanding was that Codable was designed to serialize Swift types, not to be able to import arbitrary JSON text into Swift nor to interoperate with every existing JSON API.
>> 
>> 
>> -- 
>> Greg Parker     gparker at apple.com     Runtime Wrangler
>> 
>> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170623/481afd91/attachment.html>


More information about the swift-users mailing list