Thank's Tatu,

As you said, Jackson only deserializes polymorphically if the target type 
indicates it via resolver or default typing. However, if you e.g. serialize 
an object with Java writeObject 
<https://docs.oracle.com/javase/7/docs/api/java/io/ObjectOutputStream.html#writeObject(java.lang.Object)>
 and 
readObject 
<https://docs.oracle.com/javase/7/docs/api/java/io/ObjectInputStream.html#readObject()>
 
again, the result has correct type and properties, which is because Java 
serialization always add's the type (which is possible for Jackson too, but 
ubiquitous, so much more complex than needed).

So a class, that holds heterogenous types in an Object property is not 
transferable, unless you globally configure, that all Objects have to be 
serialized with a type attribute. It's certainly possible to define 
Serializers/Deserializers, that achieve the needed polymorphic 
deserialization, but it could be *much simpler*, if there'd be an option at 
least for deserialization, that says, if there is a type attribute at the 
beginning, create this type, rather than a natural one. Of course, this 
could only be used in secured environments, but would ensure readable and 
compact JSON without the need to think about deserialization at all.

Marc



-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/1641dda2-8a24-42ba-9034-0a75a6576fff%40googlegroups.com.

Reply via email to