Serialization woes

Serialization woes

I have been pretty satisfied with default Delphi serialization techniques using published directive and DefineProperty. For most needs you don't need much more, you can publish properties declared in ancestor classes.
The only down side (occurring, rather rarely) is that you cannot un-publish published property and you cannot change property names, but those can be taken care of rather easily with simple serialization frameworks that enable you to add mappings, filters an converters.
Another important feature is that this kind of serialization allows changing serialization frameworks without the need for changing classes that need to be serialized. And it works rather fast.

Recently introduced JSON serialization in Delphi, that relies on attributes, is anything but above. You have to pollute classes with specifics valid only for this serialization framework (imagine, if you need to change it or add more), you cannot add attributes in ancestor classes (see linked SO question) and in general it creates high coupling between classes and serialization framework.

It seems to me that attribute based serialization is the worst possible serialization imaginable. 
http://stackoverflow.com/q/29317468/4267244

Comments