On Fri, Apr 29, 2016 at 4:06 PM, Andrew Dunstan <and...@dunslane.net> wrote:
> One other point: I think we really need most of these pieces - if we are
> going to squash the whitespace we need functions to do that cleanly for json
> and to pretty-print json.

I don't think it should be squashed per se -- we just don't *add* any
whitespace.  So the current behavior of to_json,

postgres=# select to_json(q) from (select 1, '{"a"  :  "foo"}'::json) q;
                to_json
───────────────────────────────────────
 {"?column?":1,"json":{"a"  :  "foo"}}

...is correct to me on the premise that the user deliberately chose
the whitespace preserving json type and did not run compat on it.
However,
postgres=# select row_to_json(q) from (select 1, '{"a"  :  "foo"}'::jsonb) q;
             row_to_json
─────────────────────────────────────
 {"?column?":1,"jsonb":{"a": "foo"}}

really ought to render (note lack of space after "a"):
 {"?column?":1,"jsonb":{"a":"foo"}}

This is a simple matter of removing spaces in the occasional C string
literal in the serialization routines and adding a json_pretty
function.

merlin


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to