Reputation: 193
I am trying to deserialise the following Json
using Jackson
.
[
{
"id" : "abc",
"deleted": true
},
{
"id" : "def",
}
]
I do not want to create java objects for items that are marked "deleted":"true"
.
For the above example, output objects for my above JSON structure should be a List with just one object(id:def).
How can I configure jackson to do this?
Upvotes: 0
Views: 785
Reputation: 83527
You can use Jackson to read a stream of JSON data. See this tutorial for details. This will allow you to decide on the fly whether or not to create any object being parsed.
Alternatively, check out javax.json.stream. This library allows pull parsing which gives you the control you want over parsing your JSON.
In general, the terms you are looking for are "push parsing" and "pull parsing". Use those to find other alternatives to accomplish what you want.
Upvotes: 1