[英]Jackson (Java) : deserialization for the same property name but return different objects. for one it return object and second List<Object>
I have a POJO like this:我有一个这样的 POJO:
public class NewClass {
String name;
@JsonProperty("productType")
ProductType productType2005;
List<ProductType> productType;
}
I want to deserialize json into Pojo.我想将 json 反序列化为 Pojo。 The issue is I have property name same productType but I can expect two different return types or data structures.
问题是我的属性名称相同 productType 但我可以期待两种不同的返回类型或数据结构。
ProductType
objectProductType
List<ProductType>
since property name is the same how can I effectively use Jackson annotations to get it resolved? List<ProductType>
因为属性名称相同我如何有效地使用 Jackson 注释来解决它? I'm using rest-assured for deserialization and Lombok for typical getter and setters.我使用 rest-assured 进行反序列化,使用 Lombok 进行典型的 getter 和 setter。
To my knowledge, this isn't possible.据我所知,这是不可能的。 A solution would be to expect a List of ProductType objects with a minimum of at least one if required.
一个解决方案是期望一个 ProductType 对象列表,如果需要,至少有一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.