-
Notifications
You must be signed in to change notification settings - Fork 27
Description
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:
{
"firstName": "John",
"lastName": "doe",
"age": 26,
"address": {
"streetAddress": "naist street",
"city": "Nara",
"postalCode": "630-0192"
},
"phoneNumbers": {
"mobile": {
"type": "iPhone",
"number": "0123-4567-8888"
},
"work": {
"type": "land line",
"number": "0123-4567-8910"
}
}
}
To extract the keys of the address
object, you would evaluate the JSONPath expression $.address.*~
or $.address[*~]
resulting in:
[
"streetAddress",
"city",
"postalCode"
]
To extract the keys of the phoneNumbers object, you would use the JSONPath expression $.phoneNumbers.*~
or $.phoneNumbers[*~]
, resulting in:
[
"mobile",
"work"
]
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
Function:
keys()
Description: Provides the property keys (An alternative for terminal tilde ~)
Output type:Set<E>