2017-07-06 84 views
0

我有這個JacksonXML列表複製標籤

@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

我發現解決方案只是使用@JacksonXmlElementWrapper(useWrapping = false) 列表屬性。

謝謝!