Type: New Feature
Affects Version/s: None
Fix Version/s: 1.5
Number of attachments :
Although I feel that it is not a good idea to heavily use polymorphism (by inheritance) when exchanging data (Json != Object graph), there are cases where this is useful. And perhaps full object serialization is something Jackson could eventually do well enough.
Currently it is hard to handle sub-classing correctly and generally without having a way to embed class information in Json transmitted. But if class information (qualified name should be enough) was added, it would be much easier to support proper deserialization to exact types (from serialization).
This of course also renders resulting Json somewhat less portable, since impls on other languages would achieve the same result some other way. That is probably acceptable risk, given that no one has to use such feature.
So.... It would make sense to have simple serialization/deserialization feature that:
- On writer (serialization) side would include "class" (or, "@class"?) member in beans that are serialized as Json Objects
- On reader (deserialization) side would look for the same member, and use that class as the value type, instead of declared type, or annotation-derived type.
In addition to global setting, perhaps similar annotation should be added that could be attached to class (to add such class declaration for class itself) and setters/getters (to add declaration for property method represents, iff it's serialized as a Json Object).
One thing to note is that this would not allow specifying container type of Collections, but it would still work for contents. This is probably acceptable deficiency as well.