Tips / Warnings? This can be serious code. I suggest that it is easier to write simple code that transforms your existing model into a simple DTO that can be serialized trivially according to your choice of an existing serialization API. The presence of the DTO level (separate from the domain objects) also allows to simplify the maintenance significantly - you can reorganize your domain objects without violating the serialized data.
The parameters for this are yourselves (remember that you emphasized that the model is quite complex and you are not a bit violinist):
- Manually record serialization of record type very easy to make mistakes, very laborious.
- write a general library; crazy amounts of work solving all edge cases
And after that, you realized the serialization format, which works reliably, extensibly and supports the scripts you need (inheritance, etc.).
source share