pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Davin Shearer <davin@apache.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Emitting JSON to file using COPY TO
Date: Fri, 8 Dec 2023 16:26:40 -0500
Message-ID: <8f98a14d-c5ee-49f8-8ea4-214405a3e291@joeconway.com> (raw)
In-Reply-To: <bfb8b746-148a-47e4-a5c1-51156bcb7e89@manitou-mail.org>
References: <bfb8b746-148a-47e4-a5c1-51156bcb7e89@manitou-mail.org>

On 12/8/23 14:45, Daniel Verite wrote:
> 	Joe Conway wrote:
> 
>> copyto_json.007.diff
> 
> When the source has json fields with non-significant line feeds, the COPY
> output has these line feeds too, which makes the output incompatible
> with rule #2 at https://jsonlines.org  ("2. Each Line is a Valid JSON
> Value").
> 
> create table j(f json);
> 
> insert into j values('{"a":1,
> "b":2
> }');
> 
> copy j to stdout (format json);
> 
> Result:
> {"f":{"a":1,
> "b":2
> }}
> 
> Is that expected? copy.sgml in 007 doesn't describe the output
> in terms of lines so it's hard to tell from the doc.

The patch as-is just does the equivalent of row_to_json():
8<----------------------------
select row_to_json(j) from j;
  row_to_json
--------------
  {"f":{"a":1,+
  "b":2       +
  }}
(1 row)
8<----------------------------

So yeah, that is how it works today. I will take a look at what it would 
take to fix it.


-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com






view thread (163+ messages)  latest in thread

Message-ID: <8f98a14d-c5ee-49f8-8ea4-214405a3e291@joeconway.com>
Permalink:  ../8f98a14d-c5ee-49f8-8ea4-214405a3e291@joeconway.com/
Also on:    postgresql.org/message-id/8f98a14d-c5ee-49f8-8ea4-214405a3e291@joeconway.com

 · 

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-general@postgresql.org
  Cc: mail@joeconway.com, daniel@manitou-mail.org, andrew@dunslane.net, davin@apache.org, pgsql-hackers@postgresql.org
  Subject: Re: Emitting JSON to file using COPY TO
  In-Reply-To: <8f98a14d-c5ee-49f8-8ea4-214405a3e291@joeconway.com>

* 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