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