title: Postgres get multiple rows into a single json object
body: <p>I have a users table with columns like <code>id</code>, <code>name</code>, <code>email</code>, etc. I want to retrieve information of some users in the following format in a single json object:</p>
  
  <pre><code>{
      "userId_1" : {"name" : "A", "email": "A@gmail.com"},
      "userId_2" : {"name" : "B", "email": "B@gmail.com"}
  }
  </code></pre>
  
  <p>Wherein the users unique <code>id</code> is the key and a json containing his information is its corresponding value.</p>
  
  <p>I am able to get this information in two separate rows using <code>json_build_object</code> but I would want it get it in a single row in the form of one single json object.</p>