Swiftpack.co - Package - cherrywoods/swift-meta-serialization

MetaSerialization

Carthage compatible Build Status codecov

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 Encoder and Decoder implementation that delegate a small part of their work to implementations of MetaSupplier / Unwrapper, but are furthermore extendible. Most common use cases should however not require overriding eigther MetaEncoder or MetaDecoder, but should be archivable with a short custom implementation of MetaSupplier / Unwrapper. In the most extreme form, it is possible to build codable support for an existing framework in 2 lines of code.

Installation

MetaSerialization supports these dependency managers:

Documentation

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).

Limitation

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.

Testing

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.

MetaSerialization uses Quick and Nimble for testing.

Checkout the source-only branch, if you aren't interested in the contained examples and the tests.

Versions

Swift version

| Swift Version | MetaSerialization Version | | ------------- | ------------------------- | | >= 4.1 | >= 2.0 | | 4.0 | 1.0 |

2.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.

1.0

Version 1 was very similar to Foundations JSONEncoder implementation. Almost everything way declared open.

Licensing

This framework is licensed at the Apache Version 2.0 License, (nearly) the same license swift is licensed at.

Github

link
Stars: 8
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

v2.0 - Apr 10, 2018

  • Rewrote MetaEncoder and MetaDecoder
  • New CodingStorage concept. Useful for instant writeout to a stream.
  • Separating encoding and decoding
  • Added Utilities like ErrorContainer
  • 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.