[英]Jackson XML : How to deserialize XML using JacksonXmlElementWrapper with multiple wrapper class
I have a XML String that I need to deserialize 我有一个需要反序列化的XML字符串
<LOC attribute="example">
<VehAvail>
<VehAvailCore>
<Fees>
<Fee att1="a" att2="b" att3="c"/>
<Fee att1="x" att2="y" att3="z"/>
</Fees>
</VehAvailCore>
</VehAvail>
</LOC>
This is what I am trying with but I don't have exact solution for adding the upper two wrappers and 这是我正在尝试的方法,但是我没有添加上面两个包装和
@JacksonXmlElementWrapper(localName = "Fees")
@JacksonXmlProperty(localName="Fee")
private List<Fee> fees = new ArrayList();
How can I deserialize it into Java POJO class with JacksonXML Annotation ? 如何使用JacksonXML Annotation将其反序列化为Java POJO类?
Ok, Highlander aside, there can really be only one wrapper around a list of elements. 好的,除了Highlander ,围绕一列元素的确只有一个包装器。
In your example, you could define just 3 classes: LOC
, VehAvailCore
, and Fee
, and specify wrapper VehAvail
around VehAvailCore
, and wrapper Fees
around Fee
. 在您的示例中,您可以仅定义3个类: LOC
, VehAvailCore
和Fee
,并在VehAvail
周围指定包装器VehAvailCore
,在Fee
周围指定包装器Fees
。
Of course, it all depends on cardinalities ( minOccurs
and maxOccurs
) and what other optional elements/attributes are possible for VehAvail
, VehAvailCore
, and Fees
. 当然,这全都取决于基数( minOccurs
和maxOccurs
)以及VehAvail
, VehAvailCore
和Fees
可能还有哪些其他可选元素/属性。 Without knowing the full spec, it's impossible to tell. 如果不了解完整的规格,就无法分辨。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.