JSONpath query that returns paths to the matches

Поиск
Список
Период
Сортировка
От Alex R
Тема JSONpath query that returns paths to the matches
Дата
Msg-id CANK1NR1E1CyHcqF+xQvBYBY0+G4GGL_HKDDSad2am74zz_N3mg@mail.gmail.com
обсуждение исходный текст
Ответы Re: JSONpath query that returns paths to the matches  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-novice
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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Greg Rychlewski
Дата:
Сообщение: Streaming Replication Protocol and Logical Replication
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: JSONpath query that returns paths to the matches