Reputation: 123
I am struggling with jsonpath syntaxt. I'd like to extract two values from the following json with jsonpath.
{"data": {
"1664024100": 125,
"1664024700": 91,
"1664025300": 186,
"1664025900": 292,
"1664039100": 466,
"1664039700": 217,
"1664110500": 98
}
}
The only data I am able to extract are the values (125,91, etc.) with $.data[*]
.
What is the correct syntax to extract the timestamp as a value and what is the right syntax to extract the value.
thanks
Upvotes: 0
Views: 760
Reputation: 123
In order to get the property name, which is the case in my questions, it is required to use jsonpath-plus standard with the ~ for grabbing property names of matching items (as array)).
See https://jsonpath-plus.github.io/JSONPath/docs/ts/
So the correct syntax for my specific problem is $.data[*~]
which gives back the timestamp.
Upvotes: 1