我有一个使用JAXB生成标准XML的类。我需要更改XML以使列表节点不显示,列表内容直接显示在包含节点的列表下。
package forum11919522;
import java.util.ArrayList;
import java.util.List;
class Person {
private Property property;
public Property getProperty() {
return property;
}
public void setProperty(Property property) {
this.property = property;
}
public static class Property {
private String type;
private String location;
private List<Vehicle> vehicle = new ArrayList<Vehicle>();
/** getter setter omitted **/
}
public static class Vehicle {
private String vin;
private int year;
/** getter setter omitted **/
}
}
当前xml:
<person>
<property>
<type>personal</type>
<location>abc</location>
<vehicle>
<vin>2532</vin>
<year>2012</year>
</vehicle>
<vehicle>
<vin>125321</vin>
<year>2010</year>
</vehicle>
</property>
</person>
期望的:
<person>
<property>
<type>personal</type>
<location>abc</location>
<vin>2532</vin>
<year>2012</year>
<vin>125321</vin>
<year>2010</year>
</property>
</person>
是否可以使用MOXy?