我有一个问题是让Moxy为继承对象列表生成"好"的XML和JSON.XML查找或JSON看起来都很好,但不是同时.这是模型:
public static abstract class Animal {
private String name;
protected Animal() {
}
protected Animal(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@XmlRootElement
public static class Tiger extends Animal {
public Tiger() {
}
public Tiger(String name) {
super(name);
}
}
@XmlRootElement
public static class Lion extends Animal {
public Lion() {
}
public Lion(String name) {
super(name);
}
}
@XmlRootElement
public static …Run Code Online (Sandbox Code Playgroud)