Re: to_json(NULL) should to return JSON null instead NULL

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: to_json(NULL) should to return JSON null instead NULL
Date: 2015-08-29 20:06:32
Message-ID: 55E210C8.4070607@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/29/15 12:29 PM, Pavel Stehule wrote:
> Note that all the to_json functions are strict. In this sense it's
> quite consistent. If we change it to being called on null input,
> what should we return if a null non-scalar is passed in?
>
>
> what is correct from JSON perspective? All fields with NULL

ISTM that the whole purpose of to_json is to properly jsonify something,
and the proper json form for "undefined" is 'null', is it not?
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-08-29 20:08:50 Re: to_json(NULL) should to return JSON null instead NULL
Previous Message Jim Nasby 2015-08-29 20:03:16 Re: Fwd: Core dump with nested CREATE TEMP TABLE