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 | | ------------- | ------------------------------- | | 4.2 | 2.1.0 | | 4.1.2 | 2.0.1 | | 4.1 | 2.0 | | 4.0 | 1.0 |
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.
Help us keep the lights on
v2.1.0 - Oct 13, 2018
- Migrated to Swift 4.2
open lets are now just
v2.0.1 - Jul 1, 2018
v2.0 - Apr 10, 2018
CodingStorageconcept. Useful for instant writeout to a stream.
- Separating encoding and decoding
- Added Utilities like
- More tests.
v1.0 - Feb 9, 2018
Now MetaSerialization passes all general tests that JSONEncoder also passes (See testing branch). Therefor it provides the same functionalities as JSONEncoder and JSONDecoder.
v0.1.0 - Jan 18, 2018
Removed many errors and fixed a lot of visibility issues (but probably not all).
The code from this release still lacks testing, although the tests in this framework (and also the in swift-msgpack-serialization) succeeded.
You may already use the code, but use it with care.