Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7cpO-0061oH-Af for pgsql-general@arkaria.postgresql.org; Mon, 27 Nov 2023 14:43:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r7cpM-00EAtH-Ma for pgsql-general@arkaria.postgresql.org; Mon, 27 Nov 2023 14:43:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r7cpM-00EAt6-BL for pgsql-general@lists.postgresql.org; Mon, 27 Nov 2023 14:43:12 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r7cpJ-007cFG-Vw for pgsql-general@lists.postgresql.org; Mon, 27 Nov 2023 14:43:11 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-58d439e3e15so1218945eaf.1 for ; Mon, 27 Nov 2023 06:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701096189; x=1701700989; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zHlvz95jPoUa6pqUsgx5OYpo6ENEFbLqs87OInjAJ4M=; b=OF9O/2fanWUGKPKV5y+RDZHBS51SMdOcDaBJzDdjlYmZGa/5ZrkbRab34y2FWg5lEI 9qRCIQVTpZ35CaEkQ5m/SYeAnIakd05y9NGBTv+MbSmcufDrN96vsLUVTvC4axV6ZE/T LpQK8OTeZtTaOlEWZ1b/Z8BzhnmfFH5iC3uayJJn3pIJC43mN7bxKbXikbx1LI9ICPq/ IlceWm5flB47JSy/K8/FigpFkzchwZAPfOK1TCDdJtkq5SrdkNlz7Ys7ganO+ycbNfct vhm2dK/Kkb4IxyiHAdsankLh1czMBpxQ2nok86Lmva+A6gTvJHklkdGTf6Isjnq5tVr7 USQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701096189; x=1701700989; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zHlvz95jPoUa6pqUsgx5OYpo6ENEFbLqs87OInjAJ4M=; b=D6102F+MbMBF0NUbswSxz1ob4xFWGl0HjyhAWDvF5lsUDQeqWPXpdB3nWgYDXtiGnO cGQQqH6zpNNWJnezNPEywqyU9bp8cNvtFau2J1UCmC4SHPwV2hVexoQ3XLjIGlMC1BJh NfbfdzS/U67rKLz3ecZXK/DvCJuNF8yep9TeaX45/8o8vSX7ypAnx25mmy9Ti1eSXIjg /brPumUmu0cGRolwhiD8mJPSNqGFkuTHWrf4uhy4Lh5sNi7A/9Rw2E/J/HxCwZGqIUYL dHKZDpONelb+22vqU+1rwuN5H8V/cpiwZRbLKw9FrkpSQaxX5oMytZitmR4sk3ZE/0GP lPZA== X-Gm-Message-State: AOJu0YxdedDUvZuB74+RusNGTC14vgj+NAJjf4YLX/+oagOm6gxgDUii zO3K1SIVKTJvetIbCMZDaTfWz08YcMXe3cqm9kg= X-Google-Smtp-Source: AGHT+IHLZwCUj4cfYIQBsyJO8AnMvBrIH11piZIqn2aSjfQe5dwsJ83rzE8jcKBJpStm72Rp/3oqVlT+AOPQNSlcdMw= X-Received: by 2002:a4a:dc5a:0:b0:589:f3e3:326f with SMTP id q26-20020a4adc5a000000b00589f3e3326fmr8377387oov.0.1701096189217; Mon, 27 Nov 2023 06:43:09 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ac9:7f50:0:b0:4f6:384b:17ef with HTTP; Mon, 27 Nov 2023 06:43:08 -0800 (PST) In-Reply-To: References: From: "David G. Johnston" Date: Mon, 27 Nov 2023 07:43:08 -0700 Message-ID: Subject: Re: Emitting JSON to file using COPY TO To: Pavel Stehule Cc: Dominique Devienne , Adrian Klaver , Davin Shearer , "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000164e0b060b2352ad" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000164e0b060b2352ad Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, November 27, 2023, Pavel Stehule wrote= : > Hi > > po 27. 11. 2023 v 14:27 odes=C3=ADlatel David G. Johnston < > david.g.johnston@gmail.com> napsal: > >> On Monday, November 27, 2023, Dominique Devienne >> wrote: >> >>> There's even a JSON mode. >>> By miracle, would the JSON output mode recognize JSON[B] values, and >>> avoid the escaping? >>> >> >> I agree there should be a copy option for =E2=80=9Cnot formatted=E2=80= =9D so if you dump >> a single column result in that format you get the raw unescaped contents= of >> the column. As soon as you ask for a format your json is now embedded so= it >> is a value within another format and any structural aspects of the wrapp= er >> present in the json text representation need to be escaped. >> > > Is it better to use the LO API for this purpose? It is native for not > formatted data. > Using LO is, IMO, never the answer. But if you are using a driver API anyway just handle the normal select query result. David J. --000000000000164e0b060b2352ad Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, November 27, 2023, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

po 27. 11. 2023 v=C2=A014:27 odes= =C3=ADlatel David G. Johnston <david.g.johnston@gmail.com> napsal:
=
On Monday, November 27, 2= 023, Dominique Devienne <ddevienne@gmail.com> wrote:
There's even= a JSON mode.
By miracle, would th= e JSON output mode recognize JSON[B] values, and avoid the escaping?
<= /div>

I agree there should be a copy = option for =E2=80=9Cnot formatted=E2=80=9D so if you dump a single column r= esult in that format you get the raw unescaped contents of the column. As s= oon as you ask for a format your json is now embedded so it is a value with= in another format and any structural aspects of the wrapper present in the = json text representation need to be escaped.

Is it better to use the LO API for this purpose?=C2=A0 It is native= for not formatted data.=C2=A0

Using LO is, IMO, never the answer.=C2=A0 But if you are using a driv= er API anyway just handle the normal select query result.

David J.

--000000000000164e0b060b2352ad--