Manatee.Json
Manatee.Json copied to clipboard
Fun with attributes (serialization feature)
So, while working on a personal project, I found some things that may be nice to have for serialization that could be supported well by attributes. Of course, these would only apply in auto-serialized scenarios; other serialization methods (type registration or implementing IJsonSerializable
) could just manage these ideas on their own.
Initializers
There might be occasions where some pre- or post-serialization initialization may be desired.
Add BeforeSerialization(string)
and AfterSerialization(string)
that take the names of instance methods to run before/after serialization.
Property Sequencing
SerializeSequence(int)
would determine the sequence in which the properties were serialized. This would affect the output JSON.
DeserializeSequence(int)
would determine the sequence in which the properties were deserialized. This would allow dependent properties to be deserialized after the properties they depend on.