Does jackson (Java) provide a get-in
equivalent for lookup on a JsonNode
?
In case anyone else are interested, I just wrote it out:
JsonNode current = this.provideJson.get();
for (String k : key) {
if (current.hasNonNull(k)) {
current = current.get(k);
} else {
return Optional.empty();
}
}
if (current.isInt())
return Optional.of(current.asInt());
else
return Optional.empty();
Quite straightforward.Different methods for different types. I didn't bother with generics.
JsonNode#at
is it’s built-in equivalent
Thanks!