Additional cast methods for `JsonValue`
MikeEdgar opened this issue · 0 comments
MikeEdgar commented
As of 1.1, the JsonValue
interface provides convenience methods to cast the value to JsonObject
and JsonArray
. Is there a reason to limit things to those two cases?
Currently, the approach to get a value via a pointer looks like:
JsonObject obj = ...;
String target = ((JsonString) obj.getValue("/some/path/0/to/my/string")).getString();
It would be slightly nicer for the following:
JsonObject obj = ...;
String target = obj.getValue("/some/path/0/to/my/string").asJsonString().getString();
Similarly, methods for asJsonNumber
and asJsonBoolean
, perhaps with overloads that tolerate the ValueType
of NULL
with a default argument.