sbhatt
sbhatt

Reputation: 411

Jackson XML to Pojo - Array without wrapper

I have a list of tags with same attributes but doesn't have a wrapper element to make it as a arraylist.. how can I hold this as an arraylist in Java Spring-boot application?

   <Vouch_info>
       <Note a="sometext"/>
       <Quote b="sometext"/>
       <Currency country="US" rate="0.00"/>
       <Currency country="UK" rate="1.00"/>
       <Currency country="AU" rate="2.00"/>
       <Currency country="IN" rate="3.00"/>
       <Currency country="EU" rate="4.00"/>
       <Currency country="SA" rate="5.00"/>      
   </Vouch_info>

Upvotes: 9

Views: 4535

Answers (1)

irahavoi
irahavoi

Reputation: 390

Try to annotate your List field in your VouchInfo class like this:

@JacksonXmlProperty(localName = "Currency")
@JacksonXmlElementWrapper(useWrapping = false)
private List<Currency> currency;

Upvotes: 22

Related Questions