This is a JSON serializer for OpenD programming language.
A base exception class for all serialization exceptions.
A UDA for marking fields as serializable.
Retreive the name for this serializable
Is T marked as serializable
Is this serializable readable
Is this serializable writeable
Retreive all readable serializables for T. This includes properties and getters
Retreive all fields of type T that are serializable
Retreive all writeable serializables for T. This includes properties and setters.
This is a serialization module for OpenD programming language! It contains an API for making serializers and includes JSON serializator.
The JSON serializator is implemented via std.json.
Usage examples
Basic usage
By-design, only fields marked as serializable would be visible to serializator
Using the code above, only bar would be "visible" for serialization. Please not that @serializable can be applied to field, or getter/setter functions. A getter function is a function that returns non-void and has no parameters. A setter function is a function that returns void and has exactly 1 parameter.
Example usage with getter/setter functions:
To control how serizliation is done, @serializable attribute has a constructor that accepts a string, which is then used as a name for serializtion
If serialization fails for any reason, SerializationException is used.
Advanced usage
A common desirable behavior is to serialize structs/classes that were not originally annotated with serializable. For such use-case, it's advised to use getter/setter serialization to convert such types to another type that is easily serializable:
Writing serializers
To make a custom serializer, use any of those helper templates: serializableFields, writeableSerializables, readableSerializables. Usage should be quite obvious from their names! Here's a silly sample code that serializes a custom type T:
Please refer to the provided JSON serialization module for a comprehensive example!