I can execute
SELECT to_json(1)
SELECT to_json(1.4)
SELECT to_json('this is a nice json text')
SELECT to_json('{"become":"json"}')
SELECT to_json('null')
And everything works correctly, however, when you do:
SELECT to_json(NULL::TEXT)
You actually get postgres builtin NULL, for example, if nothing really happened when I was expecting the same result as to_json('null')for exaple SELECT to_json(someText)::TEXT FROM ..., perhaps you would expect "input", "stuff", ""and null, but instead you get "input", "stuff", ""and
My question is why SELECT to_json(NULL::TEXT)doesn't json give you null, but instead just a NULL pointer? why was this implemented as in postgres? some specific reasons?
source
share