Announcing PotentCodables

The framework aims to solve three major pain points experienced with Swift's Codable system:

  • Provide a library of fully featured implementations of popular serialization formats
  • Allow decoding and/or encoding values of unknown structure (i.e. any encoded tree of values)
  • Support polymorphic type encoding/decoding while still allowing Swift to implement Codable
  • Reduce the complexity and amount of code required to implement and test new serialization formats

With regard to the first point JSON, CBOR & ASN.1 are currently supported and support for YAML is coming in the near term.

3 Likes

You forgot to include a link! :upside_down_face:

:joy: Of course

Be mindful that using dynamic type lookup to automatically instantiate types without some sort of registration mechanism is a common security vulnerability. I would recommend against using any kind of dynamic type lookup and provide a way for code to register the set of types they expect to be able to decode at a certain point instead.

12 Likes

Good point, I hadn't really thought of that.

Interestingly, due to its existing limitations, I am working on a more expressive method that involves registering classes for the Ref and EmbeddedRef types. Once this is completed I'll remove the current method.

The Ref part of the readme is both difficult to understand and seems to contain incorrect code.

Very nice to see a CBOR Coder, it's a great format :+1:

Have you done any comparative benchmarks how it stacks up against the JSON coders (throughput / allocations / size)?

Terms of Service

Privacy Policy

Cookie Policy