Re: Emitting JSON to file using COPY TO - Mailing list pgsql-hackers

From Florents Tselai
Subject Re: Emitting JSON to file using COPY TO
Date
Msg-id CA+v5N43-F9-Wiktg_-+aqKJz+YiCNJMAh5ootDeTKkOJ=kiaHA@mail.gmail.com
Whole thread Raw
In response to Re: Emitting JSON to file using COPY TO  (jian he <jian.universality@gmail.com>)
List pgsql-hackers



On Wed, Jan 21, 2026 at 2:16 PM jian he <jian.universality@gmail.com> wrote:
hi.

rebase only.

--
jian
https://www.enterprisedb.com/

I (and others I assume) would really like to see this in 19;
glancing at the thread above and in the test cases I see this is in good shape for comitter review.
No? 

If I were to add something  it would be an example in copy.sgml 
  <para>
   When the <literal>FORCE_ARRAY</literal> option is enabled,
   the entire output is wrapped in a JSON array and individual rows are separated by commas:
   <programlisting>
COPY (SELECT id, name FROM users) TO STDOUT (FORMAT JSON, FORCE_ARRAY);
   </programlisting>
   <programlisting>
[
{"id": 1, "name": "Alice"}
,{"id": 2, "name": "Bob"}
,{"id": 3, "name": "Charlie"}
]
   </programlisting>
  </para>

Also, apologies if that has been discussed already,
is there a good reason why didn't we just go with a simple "WRAP_ARRAY" ? 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: AIX support
Next
From: vignesh C
Date:
Subject: Re: Skipping schema changes in publication