Let's say I've got my domain objects laid out so the XML looks like this:
<account id="1">
<name>Dan</name>
<friends>
<friend id="2">
<name>RJ</name>
</friend>
<friend id="3">
<name>George</name>
</friend>
</friends>
</account>
My domain object:
@XmlRootElement
public class Account {
@XmlAttribute
public Long id;
public String name;
@XmlElementWrapper(name = "friends")
@XmlElement(name = "friend")
public List<Account> friends;
}
Is there an easy way to configure JAXB to render only to a depth of 2? Meaning, I'd like my XML to look like this:
<account id="1">
<name>Dan</name>
<friends>
<friend id="2" />
<friend id="3" />
</friends>
</account>