I have following JSON, in which I want to list all parent node paths where path
attribute is present.
{
"ServiceId": {
"type": "string",
"admin": "false"
},
"NormalizedEvents": {
"type": "list",
"path": "/data/../../nEvents"
},
"Events": {
"type" : "list",
"path": "/data/../../Events"
}
}
In this case, I need output like, $.NormalizedEvents
and $.Events
.
use JSONPath options to output path instead of value.
JSONPath
$.[*][?(@.path)]
Output
[
"$['NormalizedEvents']",
"$['Events']"
]
JsonPath expressions can use the dot–notation
$.NormalizedEvents
or the bracket–notation
$['NormalizedEvents']
Online Tool : Jayway JsonPath Evaluator