MetaSerialization is a framework to simplify the creation of new serialisation libraries for the swift standard library environment (Encodable, Decodable, Codable, etc.)
It's aim is to let anyone create a serialization library that works with the swift serialization framework by nearly just writing the real serialization code.
To archive this goal, it includes a default
Decoder implementation that delegate a small part of their work to implementations of
Unwrapper, but are furthermore extendible. Most common use cases should however not require overriding eigther
MetaDecoder, but should be archivable with a short custom implementation of
In the most extreme form, it is possible to build codable support for an existing framework in 2 lines of code.
MetaSerialization supports these dependency managers:
Is available at https://cherrywoods.github.io/swift-meta-serialization/ or in the docs folder of this repository. These docs also include an introduction page that outlines the general problem that should be solved by MetaSerialization and a getting started guide.
You can find a few additional resources in the wiki tab of this repository. However those guides are mostly about version 1 and might not be helpfull for the current version.
Feel free to open an issue if you have questions about this framework. All suggestions to improve MetaSerialization or it's documentation are welcome (as long as you stick to the Code of Conduct).
MetaSerialization can only do it's work properly, if you do not use the function encode(to: ) of the Encodable protocol directly in your implementation of it. Use the encode methods of the (Un)Keyed/SingleValueEncodingContainers instead.
This project is tested against the tests of JSONEncoder from Foundation among other tests specifically designed for MetaSerialization. All test can be found in the Tests folder.
Checkout the source-only branch, if you aren't interested in the contained examples and the tests.
|Swift Version||MetaSerialization Version|
Version 2 added a bunch of features, separated encoding and decoding where necessary and provided better overriding options for
Meta(De|En)coder. However, this resulted in a more closed environment, where not everything is overridable, as it as in version 1.
Version 1 was very similar to Foundations JSONEncoder implementation. Almost everything way declared open.
This framework is licensed at the Apache Version 2.0 License, (nearly) the same license swift is licensed at.