Skip to content

NobodyNada/Serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serializer

Build Status

Swift 4's new Codable protocol makes it much simpler to serialize Swift objects. The built-in JSONEncoder and PlistEncoder encode and decode JSON and plist, but what about when you need to use other formats?

Writing a custom encoder is fairly complex, so Serializer takes care of that for you. Serializer converts your Swift objects into a simple enum, which you can easily traverse and write to a file format of your choice.

All you have to do is implement the Serializer protocol and create a method called serialize, which encodes a Serializable enum into your custom format. Decoding is similar -- add the Deserializer protocol, with a deserialize method which converts your custom format into a Serializable. Here's an example serializer and deserializer for the NBT file format.

About

Codable serialization to custom formats made easy

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages