I need to know whether I can deserialize a generic object to it's defining type without having an additional property or without mentioning the type in an annotation.
Ex:-
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
In above I have to mention the @class
property, and another way is
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = Dog.class, name = "Dog"),
@JsonSubTypes.Type(value = Cat.class, name = "Cat")
})
in the above example, we are defining the subclasses and a custom type.
Using a custome deserializer StdDeserializer<T>
Is there any other way to do this please tell me.