How can I polymorphic deserialization Json String using Java and Jackson Library?

Viewed 25682

I've some classes A, B, C they all inherit from class BaseClass.

I've a String json that contains the json representation of the A, B, C or BaseClass.

I want to have some way to deserialize this String to the BaseClass (polymorphic deserialization). Something like this

BaseClass base = ObjectMapper.readValue(jsonString, BaseClass.class);

jsonString could be Json String representation of any of A, B, C, or BaseClass.

2 Answers
Related