【发布时间】:2014-08-13 00:05:36
【问题描述】:
我在反序列化以下 xml 时遇到问题:
<root>
<apples>
<apple>
<id>1</id>
<weight>0.6</id>
</apple>
<apple>
<id>2</id>
<weight>0.7</id>
</apple>
</apples>
</root>
到java:
public class Root {
private List<Fruits> fruits;
}
在上面的 xml 源代码中,其他变体可能是例如橘子/橙色等,因为这是属性 xml,我无法更改它的架构。默认情况下,我使用@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) 和@JsonSubTypes({/*fruits subtypes listed*/})。经过几次不成功的尝试后,我不确定解决问题的正确映射/配置是什么。
【问题讨论】: