-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
I have class as follows
class XYZ {
private String type;
private TypeSpecific typeSpecific;
public TypeSpecific getTypeSpecific() {
return typeSpecific;
}
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
property = "type"
)
@JsonSubTypes({
@JsonSubTypes.Type(value = ATypeSpecific.class, name = "a")
})
public void setTypeSpecific(TypeSpecific typeSpecific) {
this.typeSpecific = typeSpecific;
}
}
Class ATypeSpecific extends TypeSpecific.
I want to deserialize JSON
{"type":"b"}
where typeSpecific will be set as null in object. But I am getting following exception:
com.fasterxml.jackson.databind.JsonMappingException: Missing property 'typeSpecific' for external type id 'type'
How do I deserialize above mentioned JSON into the object? If @JsonTypeInfo requires 'typeSpecific' property during deserialization, then is there a way to add it into JSON before deserialization?
Dependency versions:
jackson-annotations: 2.7.0
jackson-core: 2.7.4
jackson-databind: 2.7.4
samithja, DeepakPatankar and jacek-rzrz
Metadata
Metadata
Assignees
Labels
No labels