我有这个
@JacksonXmlRootElement(localName = "results")
public class GenericResults{
@JacksonXmlProperty
private String copyright;
@JacksonXmlProperty
private int count;
@JacksonXmlProperty(localName = "list")
private List<Result> list;
在Pojo上我有这个
public class Result {
@JacksonXmlProperty(isAttribute = true, localName = "symbol")
private String symbol;
@JacksonXmlProperty(isAttribute = true, localName = "datatype")
private String datatype;
@JacksonXmlProperty(isAttribute = true, localName = "entitlement")
private String entitlement;
@JacksonXmlProperty(isAttribute = true, localName = "datetime")
private Long datetime;
结果是
<results>
<copyright>Copyrights Bla Bla Bla </copyright>
<symbolCount>2</symbolCount>
<list>
<list symbolstring="x" datatype="a" entitlement="r" datetime="1499375390609"/>
<list symbolstring="y" datatype="a" entitlement="r" datetime="1499375390731"/>
</list>
</results>
我想要制作的是......
<results>
<copyright>Copyrights Bla Bla Bla </copyright>
<symbolCount>2</symbolCount>
<list symbolstring="x" datatype="a" entitlement="r" datetime="1499375390609"/>
<list symbolstring="y" datatype="a" entitlement="r" datetime="1499375390731"/>
</results>
有人可以帮帮我吗?我尝试了一些其他的东西,但我无法做到这一点......我不想让列表的重复标签....
答案 0 :(得分:0)
我发现解决方案只使用@JacksonXmlElementWrapper(useWrapping = false) 在列表属性。
谢谢!