Closed nurs-lr closed 3 years ago
Your declarations is incorrect: you cannot to use @JsonTypeInfo
in subtype if reading as base type: declaration MUST BE on Base
, not Animal
, if target type is Base
.
This is the problem here.
Update: I've used the same setup through RestAssured API and it worked as expected:
List<Animal> animals = response.as(new TypeRef<>() {}); // no exception
@cowtowncoder Thanks for looking into it!
When attempting to deserialize the JSON array to the concrete classes that are the part of a polymorphic type hierarchy, a JsonParseException is thrown due to an unrecognized field.
The error:
Dummy Example:
Trying to perform deserialization using
@JsonTypeInfo
and@JsonSubTypes
.What would be the solution to deserialize with the properties which are coming from the parent class? (trying not to write CustomDeserializer)