title: How to convert recordset to json array in postgres
body: <p>i'm having one table like </p>
  
  <pre><code>  name | age 
     abc | 20
     pqr | 30
  </code></pre>
  
  <p>I want result in json array like </p>
  
  <pre><code>{
   [{
     "name":"abc",
     "age":20 
   },
   {
    "name":"pqr",
     "age":30 
   }]
  }
  </code></pre>
  
  <p>I know their is method </p>
  
  <pre><code>row_to_json();
  </code></pre>
  
  <p>that will be give me only single row of json but i want array,
  please help me on this </p>