0
我有這樣的XML,我想讀它到POJO。 如何在不讀取屬性的情況下創建POJO: Admin,time,dirtyId ..? 我應該添加哪些json註釋(用Java編寫的代碼)?XML到POJO - 沒有地圖xml屬性
<response status="success" code="19">
<result total-count="1" count="1">
<rules admin="admin" dirtyId="39" time="2017/05/28 11:35:18">
<entry name="Shared" admin="admin" dirtyId="33" time="2017/04/03 15:24:03">
<source admin="admin" dirtyId="33" time="2017/04/03 15:24:03">
<member admin="admin" dirtyId="33" time="2017/04/03 15:24:03">ip-10.30.14.14</member>
</source>
<destination admin="admin" dirtyId="33" time="2017/04/03 15:24:03">
<member admin="admin" dirtyId="33" time="2017/04/03 15:24:03">ip-10.30.14.25</member>
</destination>
</entry>
</rules>
</result>
這是POJO代表XML中的條目:
public class PanoramaRule {
private PanoramaRuleOptions option;
private String name;
private List<String> to;
private List<String> from;
private List<String> source;
private List<String> destination;
@JsonProperty("source-user")
private List<String> sourceUser;
private List<String> category;
private List<String> application;
private List<String> service;
@JsonProperty("hip-profiles")
private List<String> hipProfiles;
private String action;
private String description;
private Boolean disabled;
public void setDisabled(String disabled) {
this.disabled = "yes".equals(disabled);
}
}
感謝, 米哈爾
你有沒有檢查這些鏈接https://stackoverflow.com/questions/14789302/parse-xml-to-java-pojo-in-efficient-way https://stackoverflow.com/questions/1651924/simple-java -xml到POJO映射結合 –