Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional cast methods for JsonValue #401

Open
MikeEdgar opened this issue Sep 13, 2023 · 0 comments
Open

Additional cast methods for JsonValue #401

MikeEdgar opened this issue Sep 13, 2023 · 0 comments

Comments

@MikeEdgar
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant