내가 한 달마 티아 클래스 "동물"에 잭슨 주석을 사용하여 자바 객체로 JSON 개체를 역 직렬화하려고 여기잭슨 직렬화 예기치 않은 토큰 (END_OBJECT),
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({@Type(value = Dog.class, name = "chien"),
@Type(value = Cat.class, name= "chat")})
및 샘플 JSON 문자열입니다 :
{
"name": "Chihuahua",
"type": {
"code": "chien",
"description": "Chien mechant"
}
}
문제는 JSON 개체의 "type"속성도 개체라는 것입니다. 내가 deserialize하려고하면 예외가 :
Caused by: org.codehaus.jackson.map.JsonMappingException: Could not resolve type id '{' into a subtype of [simple type, class Animal]
"속성"값으로 아무것도 사용하려고 시도했지만 아무 것도. Exeption is this
Caused by: org.codehaus.jackson.map.JsonMappingException: Unexpected token (END_OBJECT), expected FIELD_NAME: missing property 'type.code' that is to contain type id (for class Animal)
잘못된 것이 있습니다. 고맙습니다.
관련 없음 ... – FazoM
원하는 경우 :). – FazoM