我有rest控制器,它同时使用XML / JSON。 可以说我有以下格式的xml。
<SolutionElementList>
<SolutionElement>
<TechRegElemId>str1234</TechRegElemId>
<Secode>str1234</Secode>
<Seid>str1234</Seid>
</SolutionElement>
<SolutionElement>
<TechRegElemId>str1234</TechRegElemId>
<Secode>str1234</Secode>
<Seid>str1234</Seid>
</SolutionElement>
我将JacksonXmlElementWrapper用于包装器,如下所示。
@JacksonXmlElementWrapper(localName = "SolutionElementList")
@JacksonXmlProperty(localName="SolutionElement")
private List<SolutionElement> solutionElement;
在反序列化期间可以正常运行(POST请求后正确填充对象)。
如何使用jakson批注为同一输入的JSON格式批注POJO。 PFB JSON
"SolutionElementList": {
"SolutionElement": [
{
"TechRegElemId": "str1234","Secode": "str1234","Seid": "str1234"
},{
"TechRegElemId": "2str1234","Secode": "2str1234","Seid": "2str1234","AlarmId": "2str1234"
}
]
}