title: Select query in row_to_json function
body: <p>For example ,
  I use the following function to convert <code>rows</code> into <code>json</code> in <code>PostgreSQL 9.2</code></p>
  
  <pre><code>select row_to_json(row(productid, product)) from gtab04;
  </code></pre>
  
  <p>and this will returns below results</p>
  
  <pre><code>row_to_json
  ---------------
  {"f1":3029,"f2":"DIBIZIDE M TAB"}
  {"f1":3026,"f2":"MELMET 1000 SR TAB"}
  {"f1":2715,"f2":"GLUCORED FORTE"}
  {"f1":3377,"f2":"AZINDICA 500 TAB"}
  </code></pre>
  
  <ul>
  <li>unfortunately it loses the field names and replaces them with f1, f2, f3, etc.</li>
  <li>How can I get the actual field names or cast field name?</li>
  </ul>