[swift-evolution] Idea: Exposing _JSONEncoder and _JSONDecoder functionality
iferber at apple.com
Tue Jul 25 11:45:10 CDT 2017
This is something we’ve considered adding and may do so in the future
— however, this will require additional API review and will not make
it in time for the Swift 4.0 release.
The usage of `JSONSerialization` as the serialization backend is a
current implementation detail, and may change in future releases; it
would, for instance, be more efficient to read/write JSON as we
encode/decode, instead of trying to collect the entire object graph
before performing the next step.
We could also introduce something like a general
`StructureEncoder`/`StructureDecoder` which performs this conversion, as
this might be useful outside of just JSON. (For instance,
`PropertyListEncoder`/`PropertyListDecoder` currently do something
So yes, this is under consideration for future API. :)
On 25 Jul 2017, at 0:44, Morten Bek Ditlevsen via swift-evolution wrote:
> In the implementation og JSONEncoder and JSONDecoder we have the
> functionality that encodes Codable types to a structure that is
> with JSONSerialization.
> The JSONEncoder then calls JSONSerialization on this structure - and
> JSONDecoder vice versa.
> In some situations it could be nice to just encode or decode to or
> this structure - and not have the final encoding to Data performed.
> instance if you have some library that hands you a structure in this
> and you would like to perform decoding.
> Can anyone else see the relevance of exposing this functionality? It
> be exposed by wrapping _JSONEncoder in a public JSONStructureEncoder
> something similar.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution