Reputation: 401
I have a XML String that I need to deserialize
<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 ?
Upvotes: 2
Views: 1709
Reputation: 159096
Ok, Highlander aside, there can really be only one wrapper around a list of elements.
In your example, you could define just 3 classes: LOC
, VehAvailCore
, and Fee
, and specify wrapper VehAvail
around VehAvailCore
, and wrapper Fees
around Fee
.
Of course, it all depends on cardinalities (minOccurs
and maxOccurs
) and what other optional elements/attributes are possible for VehAvail
, VehAvailCore
, and Fees
. Without knowing the full spec, it's impossible to tell.
Upvotes: 3