pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Erwin Brandstetter <brsaweda@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-docs <pgsql-docs@postgresql.org>
Subject: Re: json_strip_nulls()
Date: Sat, 22 Jan 2022 16:00:39 -0500
Message-ID: <1489048.1642885239@sss.pgh.pa.us> (raw)
In-Reply-To: <CAGHENJ4Wgfvj6BPo3xeJZ94MSDWaszam3pZ24ydHahXQRzn+NA@mail.gmail.com>
References: <CAGHENJ5OckBWa22Cf=N9e68EZM2=_S8AWjWF-_xnGa+iktUh7g@mail.gmail.com>
	<CAKFQuwYeVypxm+oY9WvnxeJLgyZWCfNdf6_M-3EKjbSgMoPmXQ@mail.gmail.com>
	<CAGHENJ4Wgfvj6BPo3xeJZ94MSDWaszam3pZ24ydHahXQRzn+NA@mail.gmail.com>

Erwin Brandstetter <brsaweda@gmail.com> writes:
> On Sat, 22 Jan 2022 at 20:31, David G. Johnston <david.g.johnston@gmail.com>
> wrote:
>> json_strip_nulls doesn't make any promise regarding its output json other
>> than that it is valid.  Since we are munging the json we are arguably
>> within our rights to output whatever transformed version we want.  The
>> format should not be documented.

> Within our rights, maybe. The manual makes related promises[1]:
>> Because the json type stores an exact copy of the input text, it will
>> preserve semantically-insignificant white space between tokens
> And[2]:
>> As previously stated, when a JSON value is input and then printed without
>> any additional processing, json outputs the same text that was input,

"Without any additional processing" is the key restriction there.

> Not strictly contradicting, but the current behavior of json_strip_nulls()
> is still surprising. Either the input should be preserved as far as
> possible or, failing that, the actual behavior documented.

It is documented --- you just quoted the text that does so.

I don't have a lot of sympathy for "JSON-reading" code that fails to
conform to the JSON RFC, so I'm disinclined to work harder than that.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <1489048.1642885239@sss.pgh.pa.us>
Permalink:  ../1489048.1642885239@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1489048.1642885239@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, brsaweda@gmail.com, david.g.johnston@gmail.com
  Subject: Re: json_strip_nulls()
  In-Reply-To: <1489048.1642885239@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox