Re: change JSON serialization for BIGINT?

From: Victor Yegorov <vyegorov(at)gmail(dot)com>
To: Tim McLaughlin <tim(at)gotab(dot)io>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: change JSON serialization for BIGINT?
Date: 2024-11-26 11:36:26
Message-ID: CAGnEbohqVqmA6gJgKmHqANMYHNtyAxv-3U3izEUVfoKoMZp-FA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

вт, 26 нояб. 2024 г. в 14:34, Tim McLaughlin <tim(at)gotab(dot)io>:

> 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));

--
Victor Yegorov

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim McLaughlin 2024-11-26 13:07:13 Re: change JSON serialization for BIGINT?
Previous Message Tim McLaughlin 2024-11-26 11:34:06 change JSON serialization for BIGINT?