[英]Jackson deserialize array of json objects ignoring some of the objects
Suppose I have this JSON Array 假设我有这个JSON数组
[{"type":"type1", "id":"1", "name":"John"},
{"type":"type1", "id":"2", "name":"Jane",
{"type":"type2", "id":"3", "name":"Joseph"}]
And I have these Java objects 我有这些Java对象
public class Person {
Long id;
String name;
String type;
}
public class MainClass {
List<Person> persons;
}
Is there a way to deserialize the JSON array such that only those that are type type1 will be included? 有没有一种方法可以反序列化JSON数组,以便仅包含类型为type1的那些数组? Those with type2 should not be set as null but completely ignored. type2的那些不应设置为null,而应完全忽略。
我认为您可以使用Jackson Filter实现
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.