Re: Emitting JSON to file using COPY TO

Поиск
Список
Период
Сортировка
От Davin Shearer
Тема Re: Emitting JSON to file using COPY TO
Дата
Msg-id CALvfUkBKTr9WLAbHQYmwZ7SVp5_VDey1F1uCZtKL4+H1-WvyBw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Emitting JSON to file using COPY TO  (Joe Conway <mail@joeconway.com>)
Ответы Re: Emitting JSON to file using COPY TO  (Joe Conway <mail@joeconway.com>)
Список pgsql-hackers
" being quoted as \\" breaks the JSON. It needs to be \".  This has been my whole problem with COPY TO for JSON.

Please validate that the output is in proper format with correct quoting for special characters. I use `jq` on the command line to validate and format the output. 

On Sun, Dec 3, 2023, 10:51 Joe Conway <mail@joeconway.com> wrote:
On 12/3/23 10:31, Davin Shearer wrote:
> Please be sure to include single and double quotes in the test values
> since that was the original problem (double quoting in COPY TO breaking
> the JSON syntax).

test=# copy (select * from foo limit 4) to stdout (format json);
{"id":2456092,"f1":"line with ' in it:
2456092","f2":"2023-12-03T10:44:40.9712-05:00"}
{"id":2456093,"f1":"line with \\" in it:
2456093","f2":"2023-12-03T10:44:40.971221-05:00"}
{"id":2456094,"f1":"line with ' in it:
2456094","f2":"2023-12-03T10:44:40.971225-05:00"}
{"id":2456095,"f1":"line with \\" in it:
2456095","f2":"2023-12-03T10:44:40.971228-05:00"}

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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Dumped SQL failed to execute with ERROR "GROUP BY position -1 is not in select list"
Следующее
От: Alexander Korotkov
Дата:
Сообщение: Re: collect_corrupt_items_vacuum.patch