Hi all

With Swift 4 Codable support, we can now do the following conversions:

  1.  Codable <-> Data using JSONEncoder/JSONDecoder
  2.  Any <-> Data using JSONSerialization

Not sure if I missed something obvious, but is there a simple way to do Codable 
<-> Any conversions? I can do Codable <-> Data <-> Any conversions to get the 
same results, but I doubt that's an efficient method to achieve my needs.

Looking through Foundation source code, I believe the fileprivate class 
_JSONDecoder enables the Any -> Codable conversion that I want:
https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/JSONEncoder.swift#L867-L868

However, it's not public and hence not currently usable in my code without 
copy/pasting the source code from Foundation to my package.


Youming Lin
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to