to_json(NULL) should to return JSON null instead NULL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: to_json(NULL) should to return JSON null instead NULL
Date: 2015-08-29 06:39:00
Message-ID: CAFj8pRBdi4Ud-=8kfM28i7fa=B6t=nFTM3UK5qNBm9TjazC99A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

currently JSON support NULL value - but we doesn't convert NULL to JSON
correctly

postgres=# select to_json(NULL::text) IS NULL;
┌──────────┐
│ ?column? │
╞══════════╡
│ t │
└──────────┘
(1 row)

probably should be json "null";

like

postgres=# select json 'null' is null;
┌──────────┐
│ ?column? │
╞══════════╡
│ f │
└──────────┘
(1 row)

?

Regards

see:
http://stackoverflow.com/questions/32283125/why-cant-null-be-converted-to-jsons-null-in-postgresql
http://stackoverflow.com/questions/21120999/representing-null-in-json

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shulgin, Oleksandr 2015-08-29 12:47:44 Re: to_json(NULL) should to return JSON null instead NULL
Previous Message Noah Misch 2015-08-29 05:42:39 Re: [BUGS] Compile fails on AIX 6.1