-
Notifications
You must be signed in to change notification settings - Fork 263
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
Option for json.path.read to return path instead of value #870
Comments
More generally, I think it would make sense to add a third parameter, "configuration", that is a json object containing the five Jayway configuration options:
|
@cwisniew I know you are working on JSON stuff, what do you think of this? |
- Add third parameter "config" to json.path.read, which can take the following values: ALWAYS_RETURN_LIST, AS_PATH_LIST, DEFAULT_PATH_LEAF_TO_NULL, REQUIRE_PROPERTIES, SUPPRESS_EXCEPTIONS - Add javadocs - Close RPTools#870
PR #871 implements this. |
- Add third parameter "config" to json.path.read, which can take the following values: ALWAYS_RETURN_LIST, AS_PATH_LIST, DEFAULT_PATH_LEAF_TO_NULL, REQUIRE_PROPERTIES, SUPPRESS_EXCEPTIONS - Close RPTools#870
PR #1112 implements this. |
Documentation updated: json.path.read |
Testing new parameters. |
Going to need an example of what REQUIRE_PROPERTIES is used for. Didn't see it in the Jayway docs. |
https://www.javadoc.io/doc/com.jayway.jsonpath/json-path/2.0.0/com/jayway/jsonpath/Option.html Doc actually had an example, go figure lol (didn't expect it to be helpful) Hopefully this it's the same thing at least... |
What?! Useful examples in a javadoc? That definitely helps. |
All config options tested. |
Is your feature request related to a problem? Please describe.
Sometimes I want to get the indexes of a json.array containing nested elements.
For example, if I have a json array containing Spells as json objects, I'd like to get the indexes of the spells with a specific value in a field instead of the spells themselves.
Describe the solution you'd like
A way to return the paths instead of the values when running a
json.path.read
statement. A way to do so would be to augment thejson.path.read
:json.path.read(json, path, asPath)
where
asPath
can take the value 1 (to return path) or 0 (to return value).Additional context
The Jayway library already contains this capability, by using
The text was updated successfully, but these errors were encountered: