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"}
I tried doing this, but it has no effect:
CREATE or replace FUNCTION bigintJson(bigint) RETURNS json
AS 'select $1::text::json;'
LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT;
create cast (bigint as json) with function bigintJson(bigint) as implicit;
Thanks for any guidance.
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"}
I tried doing this, but it has no effect:
CREATE or replace FUNCTION bigintJson(bigint) RETURNS json
AS 'select $1::text::json;'
LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT;
create cast (bigint as json) with function bigintJson(bigint) as implicit;
Thanks for any guidance.
--
Tim McLaughlin
Tim McLaughlin