Hi,
I am trying to figure out whether Postgres 14 allows me to find the paths to certain values in the JSON, rather than the values themselves. To illustrate, here is a test query:
SELECT JSONB_PATH_QUERY($${
"this": "that",
"that": [{"x": "aaa"},{"y": "missed"}],
"nested": {
"deep": {
"x": "bbb"
}
}
}$$, 'strict $.**."x"');
It returns 2 matches: "aaa" and "bbb". However, what I'd like to get instead is 2 paths that point to the matches, i.e.,:
- $.that[0]
- $.nested.deep
Can this be accomplished using means that are available out of the box? If not, what would be a sane way of implementing it?
Thank you for your help,
Alex