Let I have a JSONb data:
{
"track": {
"segments": [
{
"location": [ 47.763, 13.4034 ],
"start time": "2018-10-14 10:05:14",
"HR": 73
},
{
"location": [ 47.706, 13.2635 ],
"start time": "2018-10-14 10:39:21",
"HR": 135
},
...
]
}
}
I have the JSONPath expression $.track.segments ? (@.location[1] < 13.4)
that finds the desired objects in an array (returns the 2nd object in the example array $.track.segments
).
Then I need to modify the found object in the original JSONb data.
As answered here How to modify field with jsonPath in PostgreSQL?
I need to use jsonb_set
function.
How do I get the path of the found object that is suitable for passing to the jsonb_set
function? (In this example, the value is '{track,segments,2}'
)
Or, at least, the index of the found object in the segments
array?