I have the following JSON list:
[
{
"name": "John Doe The First",
"age": 36
},
{
"name": "John Doe The Second",
"age": 10
}
]
And the following Java record:
public record Person(String name, int age) {}
Is it possible to Jackson not parse JSON entries matching a condition such as age under 18 without writing a Consumer and filtering out these JSonNodes as indicated in this answer?
What I want is described in the third and, until now last, comment of this very answer.
EDIT:
Based on Hiran Chaudhuri's answer it makes perfect sense that is impossible to the parser to not parse the entire file which leads me to a second question. Isn't possible to Jackson, once the JsonNode is converted into a POJO, to filter these ones out based on the described conditions?
Something similar to what @JsonFilter does but not forcing developers to write a filter based on the Stream backed by the array returned nor creating a whole new filtered list, the array returned would contain just what is needed.