JSON NULLs

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема JSON NULLs
Дата
Msg-id A62DDF0A-81DF-4988-9440-F038B46D60D6@justatheory.com
обсуждение исходный текст
Ответы Re: JSON NULLs
Список pgsql-hackers
Hackers,

While playing with Andrew’s JSON enhancements, I noticed this:
   david=# select * From json_each_as_text('{"baz": null}'::json);    key | value    -----+-------    baz | null

It is returning 'null'::text there, not NULL::text. I had expected the latter, because otherwise it's not possible to
tellthe difference between '{"foo": null}' and '{"foo": "null"}'. 

But then I noticed that this seems to be true for JSON NULLs in general:
   david=# select 'null'::json::text IS NULL;    ?column?    ----------    f

Again, I expected a NULL there. I recognize that JSON NULLs are not the same as SQL NULLs, but if there is no way to
tellthe difference, well, it’s annoying. 

I see that '"null"'::json::text resolves to '"null"'::text, so that’s one way to deal with it. But since
json_each_as_textreturns values as text, not quoted JSON values, maybe *it* should return JSON NULLs as SQL NULLs? 

Thanks,

David




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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: palloc unification
Следующее
От: Andres Freund
Дата:
Сообщение: Re: palloc unification