I have a table
key | value
-----+-------
a | "foo"
b | "bar"
How can I get the result
{"a": "foo", "b": "bar"}
It doesn't work with
select array_to_json(array_agg(t)) from table t; -- I get [{"key": "a", "value": "foo"}, {"key": "b", "value": "bar"}]
Can you help me?