Re: BUG #14354: Wrong interpretation of JSON 'null'

Поиск
Список
Период
Сортировка
От Kouber Saparev
Тема Re: BUG #14354: Wrong interpretation of JSON 'null'
Дата
Msg-id CAN4RuQsL=Zp_W0fZGhT_UptvY+uPDFGOkx5zv15bbBt2a3LGSw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14354: Wrong interpretation of JSON 'null'  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
It looks like I do not know enough about the JSON type and I was treating
it always like an object with keys and values. You are absolutely correct,
now I see that I can really:

db=# select '2'::jsonb;
 jsonb
-------
 2
(1 row)

Which explains everything.

Cheers,


2016-10-06 15:47 GMT+03:00 Tom Lane <tgl@sss.pgh.pa.us>:

> Kouber Saparev <kouber@gmail.com> writes:
> > Okay, I also saw in the source code that it is looking for an
> _json-object_
> > (whatever that means) and is throwing that error otherwise. The thing is
> -
> > in my perception the string 'null' , being valid json(b), should also be
> > treated as valid _json-object_, isn't it?
>
> No.  A JSON "object" is something with field names and values, like a
> Perl hash.  JSON also has scalars and arrays; those are JSON values,
> but not JSON objects.  'null' is a scalar, I think, although for some
> purposes it might be better to view it as a fourth primitive kind of
> JSON value.
>
> jsonb_each_text() needs to work on a JSON object because otherwise its
> return convention of returning a set of field names and values makes
> no sense.  What would you imagine jsonb_each_text('2'::jsonb) ought
> to do?  Similarly, there's not really any sensible interpretation
> of jsonb_each_text('null'::jsonb).
>
> > ... I felt its an
> > inconsistency in PostgreSQL itself.
>
> The distinction between objects and other kinds of JSON values is
> drawn in the JSON standard; we did not make it up.  See
> http://rfc7159.net/rfc7159
>
>                         regards, tom lane
>

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

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: BUG #14243: pg_basebackup failes by a STATUS_DELETE_PENDING file
Следующее
От: Marco Colombo
Дата:
Сообщение: Re: BUG #14351: Upsert not working in case of partitioned tables