Open hattesen opened 2 weeks ago
Here are a couple of links to issues regarding keys()
and "terminal tilde" support in the JsonPath GitHub repository:
@hattesen, I agree that it should be included in the comparisons, it's supported in the most widely used javascript implementation, I'd suggest submitting a pull request that covers this feature for @cburgmer's consideration.
Fork the repository and in the queries directory, create a new subdirectory with a name that follows the conventions, something like "terminal_tilde_for_extracting_keys". Include two files, document.json and selector, that contain the JSON document and JSONPath selector respectively.
Quite a few JSONPath implementations support "terminal tilde" notation to extract object keys (rather than values), but I have come across issues raised on a few, that do NOT support the "terminal tilde" notation, while searching for any formal description of the notation.
It would be nice to have the "terminal tilde" support included in the json-path-comparison overview.
Examples evaluated using JSONPath online evaluator:
To extract the keys of the
address
object, you would evaluate the JSONPath expression$.address.*~
or$.address[*~]
resulting in:To extract the keys of the phoneNumbers object, you would use the JSONPath expression
$.phoneNumbers.*~
or$.phoneNumbers[*~]
, resulting in:The only specification documentation of the "terminal tilde" JSONPath notation that I have been able to locate is https://github.com/json-path/JsonPath#functions