如何用jackson解析xml列表?

e4yzc0pl  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(262)

我使用以下代码将源xml转换为json。
但是当我试图访问我的参考列表时,列表是空的。
你能解释一下我做错了什么吗?
课程项目:

public class ReportItem {
    @JsonProperty private String indice;
    @JsonProperty private String location;

    @JacksonXmlElementWrapper(localName = "References")
    private List<Reference> References = new ArrayList<>();

}

课程参考:

public class Reference {
    @JsonProperty private String Database;
    @JsonProperty private String URL;

    public Reference(String Database, String Url){
        this.Database = Database;
        this.URL = Url;
    }
}

输入xml:

<Items>
    <indice>qwerty</indice>
    <location>12.13</location>
    <References>
        <Reference>
            <Database>aaa</Database>
            <URL>bbb</URL>
        </Reference>
        <Reference>
            <Database>ccc</Database>
            <URL>ddd</URL>
        </Reference>
        <Reference>
            <Database>eee</Database>
            <URL>ggg</URL>
        </Reference>
    </References>
</Items>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题