dh1
dh1

Reputation: 127

jackson polymorphic deserialization for non-abstract parent class

This is similar to jackson polymorphic deserialize for non-abstract parent class but I can't use @JsonTypeInfo annotations because the serializaled JSON I can't change in my scenario.

public class Animal{
// Animal details
}

public class Dog extends Animal{
//Dog details

}

public class Cat extends Animal{
//Cat details

}

But there is a little problem: because my parent class (Animal) is not abstract, Jackson just deserializes all jsons into Animal class and while it does that, it fails because some of the fields present in child classes is of course not present in it.

Thanks in advance!

Upvotes: 0

Views: 53

Answers (0)

Related Questions