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 1tFts2-00HGAt-Ol for pgsql-general@arkaria.postgresql.org; Tue, 26 Nov 2024 11:36:42 +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 1tFts1-006LcD-3i for pgsql-general@arkaria.postgresql.org; Tue, 26 Nov 2024 11:36:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFts0-006Lc5-PC for pgsql-general@lists.postgresql.org; Tue, 26 Nov 2024 11:36:40 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tFtry-0047kz-KG for pgsql-general@lists.postgresql.org; Tue, 26 Nov 2024 11:36:40 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-aa549f2fa32so332722266b.0 for ; Tue, 26 Nov 2024 03:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732620997; x=1733225797; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qYqqFstH8BNGHDlSnTQkEcQyDM0588xYF2EQY1+hjMY=; b=Zw1ndo52S5SYfPy0ycMc83799R9pYrm/7EFm57WDqGbOrpIb4kpq4vMEkk4WL4/3od NFpJSKD1Dt+tFSv2JR/fjZtrF3m01Qtm2CsRGKzQAf1xhpTnwOxpI2oPj4Cp6/x8j8dE lHOjzTB0BVz5ftNzUAQxv7AQ4WKOt9ykNi82dd0nMNbffV3Y7hErsYHMznTYGZ1/ZyQn m3eXrCrxYzksGFAIlG092m/JVP04qU3jjTVM2n0CCsFxMQpAkiNOHV5BKy25FmGGdk9L sE0vZ9jNE4DGX4XyOrlcT8P3irenecSuHFC4qujcHH8sqOnojOKwZ4byFqHSQekYS87A J5MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732620997; x=1733225797; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qYqqFstH8BNGHDlSnTQkEcQyDM0588xYF2EQY1+hjMY=; b=ntDPWa9wyY4X91lVtvqtyC43KtMEMc5b3L2GkPGKHpJKOzxzRrVj0NfDluNwFYZk88 Sq0MwzTWjY329vAcyBk4yGofJgbQsrxz4U2mwzf6IUFqy8jcAI++p4J3uQIc6I0YM7Br VPJ5BjgiepTevYE+gT7S9/Y2HnQEEsVVIwllJNdqKRlpN7eKd0Rrjy0qpgr0rlMFTMkE SQtBFJIZ9j700D23q2aKhFWYVlczgRwNJic6i3iAbhWCrYj0siOZosW32LFJopbrpx3l vz+TYK5btmoyp0dYx0MdNLhRhvCi/EJBnsw6MuseJgOhvqRntzf6kCJGjl7gCJpCC9VF 2njw== X-Gm-Message-State: AOJu0YwtSJwVJlmpQM7mFOzTv34hyrCE1IdBoaHzVeLXtjuJWe2BXDDZ 6zbbAJBIrx/gkQnuiQk+fCQoRN5ull5j4xOtDYHQgd2n9sQoU6DD5c0PUOecJKRpmbi+YhEHUt6 GlU0ThDab80O3x3jT5j0lD3XurJkcIAQ19GG+xOEX X-Gm-Gg: ASbGncvf3rlHFjR+6diIcaEVjjfmm1eKZXOBTPlxxAIv2Z8O4+6CeMMACoZYjTZIQ4e jQ5MzzVsT8Xb7rfELJJHqtNRqTmda3k9JSSLrBDKAKChIyWRp3tU9wxjatRwwVuxfbA== X-Google-Smtp-Source: AGHT+IFatg6Et+GAFHB5dzgWulwt8oOtx0e97vKfgAleq59xGDfdgYbNl06jYFS5/CG9/IfWTGSsIIB/c5Ko/YKp5jE= X-Received: by 2002:a17:906:3188:b0:a99:7bc0:bca9 with SMTP id a640c23a62f3a-aa50990b300mr1411319566b.3.1732620997475; Tue, 26 Nov 2024 03:36:37 -0800 (PST) MIME-Version: 1.0 References: <536dca0f-ef1a-4621-ac1f-9c1c1dd74fbd@Spark> In-Reply-To: <536dca0f-ef1a-4621-ac1f-9c1c1dd74fbd@Spark> From: Victor Yegorov Date: Tue, 26 Nov 2024 14:36:26 +0300 Message-ID: Subject: Re: change JSON serialization for BIGINT? To: Tim McLaughlin Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000015c4eb0627cf43fc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000015c4eb0627cf43fc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D0=B2=D1=82, 26 =D0=BD=D0=BE=D1=8F=D0=B1. 2024=E2=80=AF=D0=B3. =D0=B2 14:3= 4, Tim McLaughlin : > Is there a way to have Postgres serialize BIGINT as a string rather than > number in JSON? By default it does this: > > > select row_to_json(row(500::bigint)); > row_to_json > ------------- > {"f1":500} > > But I want it to do this (note that "500" is quoted): > > select row_to_json(row(500::bigint)); > row_to_json > ------------- > {"f1":"500"} > Will this work? select row_to_json(row(500::text)); --=20 Victor Yegorov --00000000000015c4eb0627cf43fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
=D0=B2=D1=82, 26 =D0=BD=D0=BE=D1=8F=D0=B1= . 2024=E2=80=AF=D0=B3. =D0=B2 14:34, Tim McLaughlin <tim@gotab.io>:
Is there a way to have Postgres serialize BIGINT as a str= ing rather than number in JSON?=C2=A0=C2=A0By default it does this:


select row_to_json(row(500::bigint));
=C2=A0row_to_json=C2=A0
-------------
=C2=A0{"f1":500}

But I want it to do this (note that "500" is quoted):

select row_to_json(row(500::bigint));
=C2=A0row_to_json=C2=A0
-------------
=C2=A0{"f1":"500"}

Will this work?

select row_to_json(row(5= 00::text));

-- <= br>
Victor = Yegorov
--00000000000015c4eb0627cf43fc--