How to query all rows of a table into single json Postgresql?
Migrating a comment to an answer.


  I think you are looking for json_object_agg not json_agg – a_horse_with_no_name 2 hours ago


Links


JSON Functions and Operators