lets say you have:
t=# with c(v) as (select * from generate_series(1020,1029))
select json_agg(v::text) from c;
json_agg
----------------------------------------------------------------------------------
["1020", "1021", "1022", "1023", "1024", "1025", "1026", "1027", "1028", "1029"]
(1 row)
so you can:
t=# with c(v) as (select * from generate_series(1020,1029))
select translate(json_agg(v::text)::text,'"',$$'$$) from c;
translate
----------------------------------------------------------------------------------
['1020', '1021', '1022', '1023', '1024', '1025', '1026', '1027', '1028', '1029']
(1 row)
which of course is not valid json any more. And I assumed you can have only numbers, so no accidental double quote to take care of
string_agg()instead?