Search code examples
javaspring-bootjackson-dataformat-xml

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>

Solution

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

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