I am getting error when trying to deserialize json into an abstract type.
Code:
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
public abstract class Animal
{
}
public class Dog extends Animal
{
}
public class Zoo
{
Animal a;
}
@RequestMapping(value = "/zoos", method = RequestMethod.POST)
public void create(@RequestBody Zoo zoo)
{
...
}
When I post the following json to zoos:
{
"@class": "com.example.Dog",
"a": {}
}
I get the error: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "@class" (Class com.example.Zoo), not marked as ignorable
What am I doing wrong?