简体   繁体   English

杰克逊反序列化json对象数组,忽略了一些对象

[英]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.

相关问题 Jackson用对象的“伪数组”反序列化json字符串 - Jackson deserialize json string with “pseudo array” of objects 使用 Jackson 和 WebClient 将 json 数组反序列化为对象 - Deserialize a json array to objects using Jackson and WebClient 杰克逊没有忽略json数组中的空对象 - Jackson not ignoring null objects in json array 如何使用Jackson将JSON数组反序列化为Java对象 - How to use Jackson to deserialize a JSON Array into java objects 如何使用Jackson将JSON反序列化为Java对象 - How to deserialize JSON into java objects using Jackson 杰克逊试图将json反序列化为类型对象列表 - Jackson trying to deserialize json into a List of typed objects 用杰克逊反序列化json对象的对象列表-无法从start_array令牌反序列化实例 - deserializing a list of objects json object with jackson - cannot deserialize instance out of start_array token 如何使用 jackson 反序列化包含对象数组的 JSON 表示? - How do I deserialize a JSON representation containing array of objects using jackson? Jackson:尝试将 JSON 反序列化为 Java 对象时未解决的前向引用 - Jackson: Unresolved forward references when trying to deserialize JSON into java objects 如何使用Jackson将Java Enums序列化和反序列化为JSON对象 - How to serialize and deserialize Java Enums as JSON objects with Jackson
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM