Re: change JSON serialization for BIGINT? - Mailing list pgsql-general

From Victor Yegorov
Subject Re: change JSON serialization for BIGINT?
Date
Msg-id CAGnEbohqVqmA6gJgKmHqANMYHNtyAxv-3U3izEUVfoKoMZp-FA@mail.gmail.com
Whole thread Raw
In response to change JSON serialization for BIGINT?  (Tim McLaughlin <tim@gotab.io>)
Responses Re: change JSON serialization for BIGINT?
List pgsql-general
вт, 26 нояб. 2024 г. в 14:34, Tim McLaughlin <tim@gotab.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

pgsql-general by date:

Previous
From: Tim McLaughlin
Date:
Subject: change JSON serialization for BIGINT?
Next
From: Tim McLaughlin
Date:
Subject: Re: change JSON serialization for BIGINT?