json - Return Postgres json_build_object as variable field from table -
postgesql returns json_build_object parent each grouped json array this:
{ "stories": [{ "json_build_object": { "cnn": [] } }, { "json_build_object": { "fox": [] } }, { "json_build_object": { "huffpost": [] } },...
postgresql returns "json_build_object" key. possible replace stories.source value returned group by? tried alias returned error.
select json_build_object(source, json_agg(stories.*)) stories group stories.source order source;
optimal solution response this:
stories: cnn: [], fox: []...
i'm sure i'm missing best practice returning json in postgresql...
Comments
Post a Comment