[swift-corelibs-dev] JSONDecoder has too few opportunities. need an enhancement.
Norio Nomura
norio.nomura at gmail.com
Thu Nov 9 17:44:57 CST 2017
Hi Vladimir,
FYI, I also wanted to decode directly from NSDictionary and NSArray, so I
made https://github.com/norio-nomura/ObjectEncoder.
It is a simpler implementation than JSONEncoder/JSONDecoder because it does
not contain any functions to treat specific type specially.
2017-11-10 1:37 GMT+09:00 Vladimir Kushelkov via swift-corelibs-dev <
swift-corelibs-dev at swift.org>:
> 1. Sometimes it is contently to be able to decode a struct or an object
> from a Foundation object (either NSArray or NSDictionary) that produce a
> valid JSON.
> For example, if I use a 3d party library that provides *NSDictionary* to
> me. Due to *JSONDecoder* decodes only from *Data*, in the first place I
> have to convert *NSDictionary* to *Data* in order to use the one so far.
> But the decoder does the back action first thing.
> I created Pull Request <https://github.com/apple/swift/pull/12791>, that
> was closed.
>
>
> 2. Is it possible to use *JSONDecoder* when I don’t know the type of a
> particular property of the required type?
> For instance, if I develop a library that allows bi-directional
> communication between server and client. The library wraps transmitted data
> into an internal object in a way that one of the object’s properties is the data.
> So, the type of the property is unknown inside the library. I want to
> decode the internal object with JSONDecoder, but I can’t specify the type
> of one property.
>
>
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20171110/52f5c0e7/attachment.html>
More information about the swift-corelibs-dev
mailing list