How do I add array indices to the XML produced by JAXB?
- by oconnor0
I have a Java bean ala
@XmlRootElement public class Bean {
@XmlElementWrapper(name = "ints") @XmlElement(name = "int")
int[] values;
// constructors, getters, setters, etc...
}
JAXB is producing XML like
<bean>
<ints>
<int>12</int>
<int>34</int>
<int>56</int>
</ints>
</bean>
I would like the array indices to be included on the <int> tags as array position conveys important value. Preferably as attributes like
<bean>
<ints>
<int id='0'>12</int>
<int id='1'>34</int>
<int id='2'>56</int>
</ints>
</bean>
Is there a way to do this?