[swift-evolution] [Proposal] Foundation Swift Encoders
piotr.gorzelany at gmail.com
Sat Apr 8 06:28:25 CDT 2017
This is a really great proposal. As an iOS developer I work with JSON
almost every day since most mobile apps communicate with a backend through
JSON messages. It's good to see that better JSON support is coming to
Foundation so we don't have to rely on third party libraries.
That being said, there is one thing I don't like which is that the JSON
encoding function returns Data and the decoding function takes Data.
It would be really great if the Foundation team could introduce a dedicated
type of JSON.
There are several advantages of working with a dedicated type.
- The underlying data is always valid JSON
- You can extend this type in the future with helper methods for
- It makes it explicit what you are dealing with
A good analogy is the URL type. You could represent an URL with a String or
Data type, but by introducing a dedicated type you have the full advantages
mentioned above. Data on the other hand is like a generic container which
you cannot easily extend with URL or JSON specific methods.
Having a dedicated JSON type is also one of the reasons third party
libraries like SwiftyJSON are so popular. It makes it super easy to
manipulate JSON structures. And sometimes developers like would like to
manipulate JSON directly.
If the proposal would pass in the current form, I would still use
SwiftyJSON for manipulating JSON which I would rather avoid and have this
all sorted on the Foundation level.
Just my two cents from the perspective of an iOS developer. JSON handling
is really important to us so I hope you make it great!
>* On Apr 3, 2017, at 1:31 PM, Itai Ferber via swift-evolution <swift-evolution at swift.org <https://lists.swift.org/mailman/listinfo/swift-evolution>> wrote:
*>* Hi everyone,
*> >* With feedback from swift-evolution and additional internal
review, we've pushed updates to this proposal, and to the Swift
Archival & Serialization proposal.
*>* Changes to here mostly mirror the ones made to Swift Archival &
Serialization, but you can see a specific diff of what's changed here.
Full content below.
*> >* We'll be looking to start the official review process very soon,
so we're interested in any additional feedback.
*> >* Thanks!
*> >* — Itai*
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution