My json file is like this
{
"Parent1": {
"Child1":"TRUE",
"RandomKey":"TEST-111"
},
"Parent2": {
"Child1":"TRUE",
"AnotherRandomKey":"TEST-432"
}
}
My goal is to extract first occurrence of Child1 from either Parent1 or Parent2 depending on whatever exists, if both exists it should just get the first.
I have the following code written in java but it is always returning false. Not sure what i am doing wrong
final var content = Jackson.getObjectMapper().readTree(//json link);
Stream.concat(
Optional.ofNullable(content.at("/Parent1/Child1")).stream(),
Optional.ofNullable(content.at("/Parent2/Child1")).stream())
.map(JsonNode::asBoolean)
.filter(Objects::nonNull)
.findFirst()
.orElse(false);
I am trying to combine both streams and just find the first occurence of Child1 and return the boolean.