Spring Rest Jackson反序列化包装器元素

我有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"
      }
    ]
  }
wohenzhuce 回答:Spring Rest Jackson反序列化包装器元素

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2873527.html

大家都在问