Re: Emitting JSON to file using COPY TO

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Joe Conway" <mail(at)joeconway(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Emitting JSON to file using COPY TO
Date: 2023-12-08 19:45:23
Message-ID: bfb8b746-148a-47e4-a5c1-51156bcb7e89@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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.

Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2023-12-08 20:35:39 Re: Emitting JSON to file using COPY TO
Previous Message Tom Lane 2023-12-08 18:31:46 Re: Inserting into foreign table with sequences and default values

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-12-08 19:45:25 Re: micro-optimizing json.c
Previous Message Andres Freund 2023-12-08 19:33:16 Re: backtrace_on_internal_error