我有一些" root-as-list" XML:
<?xml version="1.0" encoding="UTF-8"?>
<rows code="0">
<row number="0">
<Reason_ID>1000055</Reason_ID>
<Reason_name>Недостаточно средств</Reason_name>
<Reason_externalId>DEB_LOCK</Reason_externalId>
</row>
<row number="1">
<Reason_ID>2309864</Reason_ID>
<Reason_name>Добровольная блокировка</Reason_name>
<Reason_externalId>FREE_LOCK</Reason_externalId>
</row>
<row number="2">
<Reason_ID>2310003</Reason_ID>
<Reason_name>Технологическая блокировка</Reason_name>
<Reason_externalId>TECH_LOCK</Reason_externalId>
</row>
</rows>
我怎样才能把它变成POJO?我的错误代码:
@JacksonXmlRootElement(localName = "rows")
public class GetReasonsSdpResponse extends ABaseProtocolResponse {
private static final long serialVersionUID = -7394464025399057638L;
@JacksonXmlProperty(localName = "code", isAttribute = true)
private int code;
@JacksonXmlElementWrapper(localName = "row", useWrapping = false)
private List<ReasonPart> rows = new ArrayList<>();
}
结果:GetReasonsSdpResponse{code=0, rows=[]}
PS:对不起我的英语不好,请简单说说:)
答案 0 :(得分:-2)
您使用的原因是什么: useWrapping = false
在Jackson XML annotations文档中似乎说
useWrapping(默认值:true)是否使用包装元素:通过指定'false'可以禁用使用
所以如果你想把它包含在你的解组中,我希望不要指定useWrapping = false。