From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | David Evans <david(dot)evans(at)cantab(dot)net> |
Cc: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Stability of JSON textual representation |
Date: | 2015-02-10 21:22:00 |
Message-ID: | CAHyXU0w8y04WjrXZdiyQNGhXO8-mn9RqBkMi=fJU4p5J--2UqQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Feb 9, 2015 at 3:07 AM, David Evans <david(dot)evans(at)cantab(dot)net> wrote:
> On 9 February 2015 at 03:57, Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
> wrote:
>>
>> Would using jsonb be more consistent?
>
>
> Yes, casting to jsonb seems produce consistent output:
>
> # SELECT array_to_json(array[1, 2, 3])::jsonb, json_build_array(1, 2,
> 3)::jsonb;
> array_to_json | json_build_array
> ---------------+------------------
> [1, 2, 3] | [1, 2, 3]
>
> That makes sense I suppose, given that only the structure in preserved in
> the jsonb representation.
This is not really due to whitespace/'structure only' preservation
aspects of json and jsonb, respectively. What is happening here is
that the various functions that render json from text are non
consistent in terms of spacing. Personally, I greatly prefer the
xxx_to_json functions because they don't insert spurious whitespace
making for more compact documents; putting in spaces for aesthetic
purposes is the job for a prettifier.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2015-02-10 21:23:10 | Re: Logical Decoding Callbacks |
Previous Message | John R Pierce | 2015-02-10 19:10:12 | Re: Command to reset entire PgSQL cluster? |