As a summary: I need to put some fields directly in the root tag, skipping the tag of their direct parent.
Detailed description:
I have the following classes:
@XmlRootElement
class Root{
protected Group1 group1;
protected Group2 group2;
}
@XmlRootElement
class Group1 {
protected String field1;
protected String field2;
...
protected String field99;
}
@XmlRootElement
class Group2 {
protected String field101;
...
protected String field199;
}
By default, JAXB marshalling will create this XML:
<root>
<group1>
<field1></field1>
<field2></field2>
...
<field99></field99>
</group1>
<group2>
<field100></field100>
...
<field199></field199>
</group2>
</root>
I need output to skip parent tags (group1 and group2) and include fields directly in the root element:
<root>
<field1></field1>
<field2></field2>
...
<field99></field99>
<field100></field100>
...
<field199></field199>
</root>
source
share