[英]Jackson (Java) : deserialization for the same property name but return different objects. for one it return object and second List<Object>
我有一个这样的 POJO:
public class NewClass {
String name;
@JsonProperty("productType")
ProductType productType2005;
List<ProductType> productType;
}
我想将 json 反序列化为 Pojo。 问题是我的属性名称相同 productType 但我可以期待两种不同的返回类型或数据结构。
ProductType
List<ProductType>
因为属性名称相同我如何有效地使用 Jackson 注释来解决它?我使用 rest-assured 进行反序列化,使用 Lombok 进行典型的 getter 和 setter。
据我所知,这是不可能的。 一个解决方案是期望一个 ProductType 对象列表,如果需要,至少有一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.