Re: Wildcarding json keys in json query

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Wildcarding json keys in json query
Дата
Msg-id CAKFQuwZ6P9+YaaW0A9WCCVgUn1RZfWr2c5LhU6HJT5pEiOarhg@mail.gmail.com
обсуждение исходный текст
Ответ на Wildcarding json keys in json query  (David Gauthier <davegauthierpg@gmail.com>)
Список pgsql-general
On Tue, Nov 30, 2021 at 1:40 PM David Gauthier <davegauthierpg@gmail.com> wrote:
{
ports : {
    port_abc:{min: 5, max: 7, mean: 6},
    port_def:{min: 5, max: 9, mean: 7},
    port_ghi:{min: 6, max: 10, mean: 8}
    }
}

select 1 from mytbl where cast(test_results#>'{ports,*,mean}' as float) >= 7 ;

But the "*" doesn't work :-(

Any ideas ?


If you have the option to not use data values in json field identifiers (i.e., object keys) you will avoid fighting against the system's underlying design choices.  i.e., IMO, ports should contain an array, not an object.

I was under the impression that SQL/JSON Path (jsonpath) functions/operators solve some of these kinds of problems so try using that instead of the "fixed structure" access-based functions and operators.

David J.

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

Предыдущее
От: Yi Sun
Дата:
Сообщение: Re: ssl_crl_file Certificate Revocation List doesn't work for postgresql 11
Следующее
От: Saurav Sarkar
Дата:
Сообщение: Re: Database Scalability