Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBNVD-00045k-5X for pgsql-docs@arkaria.postgresql.org; Sat, 22 Jan 2022 21:00:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nBNVA-00071m-I9 for pgsql-docs@arkaria.postgresql.org; Sat, 22 Jan 2022 21:00:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBNVA-00071d-Al for pgsql-docs@lists.postgresql.org; Sat, 22 Jan 2022 21:00:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nBNV4-0002Ci-HN for pgsql-docs@postgresql.org; Sat, 22 Jan 2022 21:00:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20ML0d4X1489049; Sat, 22 Jan 2022 16:00:39 -0500 From: Tom Lane To: Erwin Brandstetter cc: "David G. Johnston" , pgsql-docs Subject: Re: json_strip_nulls() In-reply-to: References: Comments: In-reply-to Erwin Brandstetter message dated "Sat, 22 Jan 2022 21:20:21 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1489047.1642885239.1@sss.pgh.pa.us> Date: Sat, 22 Jan 2022 16:00:39 -0500 Message-ID: <1489048.1642885239@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erwin Brandstetter writes: > On Sat, 22 Jan 2022 at 20:31, David G. Johnston > 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