0
I는 다음과 같습니다 일부 JSON이 한으로 즉시 유형을 구별 할어떻게 잭슨
ParentObj
-> ChildObj1
-> ChildObj2
-> ChildObj3
json 목록을 해당 유형으로 구문 분석 할 수 있기를 원합니다. "doesnt_exist"유형은 자동으로 실패 할 수 있습니다. 잭슨을 어떻게 사용합니까?
I는 다음과 같습니다 일부 JSON이 한으로 즉시 유형을 구별 할어떻게 잭슨
ParentObj
-> ChildObj1
-> ChildObj2
-> ChildObj3
json 목록을 해당 유형으로 구문 분석 할 수 있기를 원합니다. "doesnt_exist"유형은 자동으로 실패 할 수 있습니다. 잭슨을 어떻게 사용합니까?
Jackson에서 @JsonTypeInfo
주석을 사용해 보셨습니까? 자세한 내용은 documentation을 확인하십시오.
샘플 사용법 :
// Include Java class name ("com.myempl.ImplClass") as JSON property "class"
@JsonTypeInfo(use=Id.CLASS, include=As.PROPERTY, property="class")
// Include logical type name (defined in impl classes) as wrapper; 2 annotations
@JsonTypeInfo(use=Id.NAME, include=As.WRAPPER_OBJECT)
@JsonSubTypes({com.myemp.Impl1.class, com.myempl.Impl2.class})
I'am 그것을 시도하지만 어떻게해야합니까 : // 자바 클래스 이름 JSON 속성 "클래스"로 ("com.myempl.ImplClass")를 포함 –