public class Group {
//many other fields
public List<Person> persons;
}
public class Person {
public String name; ...
}
When I marhsal I want to get a bunch of Person nodes:
<person> <name>..</name> </person> <person> <name>..</name> </person>
instead of this: (a persons node with person nodes as children)
<persons> <person> <name>..</name> </person> <person> <name>..</name> </person> <persons>
How can I achieve this?
UPDATE
If you are referring to
personsas a grouping element rather than a root element a JAXB (JSR-222) implementation does not add one by default.Group (Without Grouping Element)
Person
Demo
Output
Group (With Grouping Element)
You need to add an
@XmlElementWrapperannotation to get a grouping elementOutput (With Grouping Element)
ORIGINAL ANSWER
You could do the following: