-
Notifications
You must be signed in to change notification settings - Fork 4
Tree Navigation
Jan Bernitt edited this page Jan 20, 2024
·
3 revisions
"Casting" to Node Types (casting does not check that actual document matches the target)
T as(Class<T extends JsonValue> type)
JsonList<T> asList(Class<T extends JsonValue> type)
JsonMap<V> asMap(Class<V extends JsonValue> type)
- and more of similar kind...
Tree Navigation
JsonValue get(String path)
JsonObject getObject(String path)
JsonArray getArray(String path)
JsonNumber getNumber(String path)
JsonBoolean getBoolean(String path)
JsonValue get(int index)
- and more of similar kind...
Drilling down...
JsonString str=root.getObject("a").getArray("b").getString(3)
// or
JsonString str=root.getString("a.b[3]")
Traversing the actual tree to find nodes
-
JsonValue#node()
: from virtual to actual JSON tree 🗱 -
JsonObect#find
: return first matchingJsonValue
-
JsonNode#visit
: visit matching nodes -
JsonNode#find
: return first matchingJsonNode
-
JsonNode#count
: count matching nodes