Re: JSON fields with backslashes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greig Wise <greigwise(at)comcast(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: JSON fields with backslashes
Date: 2023-10-13 22:01:43
Message-ID: 1593973.1697234503@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greig Wise <greigwise(at)comcast(dot)net> writes:
> Hello. I have run into an issue when using the copy command on tables
> with json columns where Postgres seems to improperly escape backslashes
> under certain conditions thus creating invalid JSON.

AFAICS this is COPY's normal behavior: it doubles backslashes in
the default format. You could use CSV format, perhaps, but that
has its own quoting rules that also mean that what comes out is
not going to be json-and-nothing-but. See "File Formats" here:

https://www.postgresql.org/docs/current/sql-copy.html

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Erik Wienhold 2023-10-14 00:09:11 Re: JSON fields with backslashes
Previous Message David G. Johnston 2023-10-13 22:01:02 Re: JSON fields with backslashes