I have a service that receives my parent interface as input in order to receive different types as input.
interface is defined as below:
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = Person.class, name = "person"),
@JsonSubTypes.Type(value = Employee.class , name = "employee")
})
public interface TestInterface {
}
and i have a service that gets TestInterface as below:
@RequestMapping(value="/convert", method = RequestMethod.POST)
@ResponseBody
public Person test(@RequestBody TestInterface object){}
this service must get json like below and works just file with type property:
{"@type":"person","name":null,"family":"fami"}
the problem is when i have a service that receives the child class directly and i don't want to specify type property.
@RequestMapping(value="/convertPerson", method = RequestMethod.POST)
@ResponseBody
public Person test(@RequestBody Person object){}
in this example when i don't send type property i get (missing type id property) exception. is there any way to make it work without type id?
i already tried the below config but it didn't solve the problem:
spring.jackson.deserialization.fail-on-missing-external-type-id-property=false
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…