Manatee.Json icon indicating copy to clipboard operation
Manatee.Json copied to clipboard

Fun with attributes (serialization feature)

Open gregsdennis opened this issue 6 years ago • 0 comments

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.

gregsdennis avatar Jan 04 '19 03:01 gregsdennis