Re: [HACKERS] SQL/JSON in PostgreSQL
От | Nikita Glukhov |
---|---|
Тема | Re: [HACKERS] SQL/JSON in PostgreSQL |
Дата | |
Msg-id | 69c22a41-ba6e-ac25-c5d6-c2aa84f89a12@postgrespro.ru обсуждение исходный текст |
Ответ на | Re: [HACKERS] SQL/JSON in PostgreSQL (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: [HACKERS] SQL/JSON in PostgreSQL
|
Список | pgsql-hackers |
On 07.01.2018 00:22, Pavel Stehule wrote:
".title" simply should go after the filter:-- not sure, if it is correctHow I can get title of book with cost 6?I am not jsonpath expert, so I can be badHiI try jsonpath on json
{
"book":
[
{
"title": "Beginning JSON",
"author": "Ben Smith",
"price": 49.99
},
{
"title": "JSON at Work",
"author": "Tom Marrs",
"price": 29.99
},
{
"title": "Learn JSON in a DAY",
"author": "Acodemy",
"price": 8.99
},
{
"title": "JSON: Questions and Answers",
"author": "George Duckett",
"price": 6.00
}
],
"price range":
{
"cheap": 10.00,
"medium": 20.00
}
}
postgres=# select j @* '$.book[*] ? (@.price==6)' from test;
┌─────────────────────────────────────────────────────┐
│ ?column? │
╞═════════════════════════════════════════════════════╡
│ { ↵│
│ "title": "JSON: Questions and Answers",↵│
│ "author": "George Duckett", ↵│
│ "price": 6.00 ↵│
│ } ↵│
│ │
└─────────────────────────────────────────────────────┘
(1 row)postgres=# select j @* '$.book[*].title ? (@.price==6)' from test;
┌──────────┐
│ ?column? │
╞══════════╡
└──────────┘
(0 rows)I found some examples, where the filter has bigger sense, but it is not supportedLINE 1: select j @* '$.book[?(@.price==6.00)].title' from test;
^
DETAIL: syntax error, unexpected '?' at or near "?"
select j @* '$.book[*] ? (@.price==6.00).title' from test;
В списке pgsql-hackers по дате отправления: