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 tell the 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 tell the 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_text returns values as text, not quoted 
JSON values, maybe *it* should return JSON NULLs as SQL NULLs?

Thanks,

David



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to