Codable encoder and decoder implementations for other formats (YAML, XML)

Are there any implementations of Encoder/Decoders for the Codable protocol besides the JSON and PropertyList one available in Foundation? It would be great to have YAML and XML decoders available.

Also, it seems that the Foundation PropertyList decoder/encoder is not available in Linux yet.

You sure? The serializer (PropertyListSerialization) seems to be complete. Take a look there, maybe we can learn what’s implemented or not for your use case.

For YAML, I can recommend https://github.com/jpsim/Yams

2 Likes

Yes, PropertyListDecoderand PropertyListEncode are not available in Swift Foundation only in the Darwin Foundation overlays (I don’t know why).

The Darwin implementation of PropertyListEncoder is open source at https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/PlistEncoder.swift so bringing it to Linux would be a matter of copying that code to swift-corelibs-foundation, fixing any corner cases / breakage, then keeping it up to date.

2 Likes

Oh, thank you! I used it a while ago and now seems to support Codable :slight_smile: