Re: Add jsonb_compact(...) for whitespace-free jsonb to text - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Add jsonb_compact(...) for whitespace-free jsonb to text
Date
Msg-id 57235F36.4020306@dunslane.net
Whole thread Raw
In response to Re: Add jsonb_compact(...) for whitespace-free jsonb to text  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: Add jsonb_compact(...) for whitespace-free jsonb to text  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Re: Add jsonb_compact(...) for whitespace-free jsonb to text  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers

On 04/28/2016 04:29 PM, Alvaro Herrera wrote:
> David G. Johnston wrote:
>> On Thu, Apr 28, 2016 at 10:00 AM, Ryan Pedela <rpedela@datalanche.com>
>> wrote:
>>> In addition, every JSON implementation I have ever seen fully minimizes
>>> JSON by default. PG appears to deviate from standard practice for no
>>> apparent reason.
>> Sorry to nit-pick but that's called convention - the standard is likely
>> silent on this point.  And its not like this was done in a vacuum - why is
>> this only coming up now and not, say, during the beta?  Is it surprising
>> that this seemingly easy-to-overlook dynamic was not explicitly addressed
>> by the author and reviewer of the patch, especially when implementation of
>> said feature consisted of a lot more things of greater import and impact?
> Actually we did have someone come up with a patch to "normalize" how
> JSON stuff was output, because our code seems to do it in three
> different, inconsistent ways.  And our response was for them to get the
> heck outta here, because we're so much in love with our current
> practice that we don't need to refactor the three implementations into a
> single one.


That's a pretty bad mischaracterization of the discussion. What was 
proposed was broken, as I pointed out to the OP, and then again later to 
you when you asked about it. What he wanted to achieve simply couldn't 
be done they way he was trying to achieve it.

Regarding the present proposal:

I wouldn't necessarily be opposed to us having one or more of the following:

a) suppressing whitespace addition in all json generation and text 
output, possibly governed by a GUC setting so we could maintain 
behaviour compatibility if required
b) a function to remove whitespace from json values, but otherwise 
preserve things like key order
c) a function to pretty-print json similar to the output from jsonb, but 
again preserving key order
d) a function to reorder keys in json so they were sorted according to 
the relevant collation.


None of these things except possibly the last should be terribly 
difficult to do.

cheers

andrew




pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: [sqlsmith] Failed assertion in BecomeLockGroupLeader
Next
From: Christian Ullrich
Date:
Subject: Re: pgsql: Support building with Visual Studio 2015