Re: Casting json (or jsonb) to real

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Casting json (or jsonb) to real
Дата
Msg-id 383082.1654046298@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Casting json (or jsonb) to real  (Wells Oliver <wells.oliver@gmail.com>)
Ответы Re: Casting json (or jsonb) to real  (Wells Oliver <wells.oliver@gmail.com>)
Список pgsql-admin
Wells Oliver <wells.oliver@gmail.com> writes:
> Well, it's because the representation of the value is getting double
> quoted, so it's
> select '"1.453"'::real, which yields ERROR:  cannot cast jsonb string to
> type real.

Oh ... that perhaps wasn't a great choice.  But it looks like you could
pretend the jsonb is a 1-element array, and do

regression=# select ('"1.4531"'::jsonb->>0)::real;
 float4 
--------
 1.4531
(1 row)

            regards, tom lane



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

Предыдущее
От: Wells Oliver
Дата:
Сообщение: Re: Casting json (or jsonb) to real
Следующее
От: jian xu
Дата:
Сообщение: RE: how to calibrate the cost model parameters