I have to instantiate a class which extends the abstract class from JSON using information in @class as shown below.
"name": {
"health": "xxx",
"animal": {
"_class": "com.example.Dog",
"height" : "20"
"color" : "white"
}
},
Here the abstract class is animal and dog extends the animal class. So using the information in @class, can we instantiate dog directly. Also this is the response I am getting in restTemplate
ResponseEntity<List<SomeListName>> response = restTemplate.exchange("http://10.150.15.172:8080/agencies", HttpMethod.GET, request, responseType);
The following error is coming when this line is executed. Since the POJO classes are auto-generated, I cannot use annotations like @JsonTypeInfo
I am using Spring boot and maven. This error is coming in console.
Could not read JSON: Can not construct instance of "MyPOJO", problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information