I am trying to generate a single json by querying from a table with id as key and email as value like this
{1: "abc@example.com", 2: "abcd@example.com"}
My attempt to create is:
select json_agg(json_build_object(id, email))
from auth_user
where id in (4733, 3625, 4961, 4237);
which results me
[{4733: "abc@example.com"}, {3625: "abcd@example.com"}]
json_object_agg
notjson_agg