title: how to convert ResultSet to JSON object
body: <p>We have tried to convert ResultSet into JSON object using following code :</p>
  
  <pre><code>var getAllCalelements = {};           // Object
      getAllCalelements['totalamount'] = [];          
      getAllCalelements['totalamount'].push(result.rows.item(i).totalamount);
      getAllCalelements['discount'] = [];          
      getAllCalelements['discount'].push(result.rows.item(i).invoicediscount);
      getAllCalelements['NetAmount'] = [];          
      getAllCalelements['NetAmount'].push(result.rows.item(i).namount);
      getAllCalelements['vat'] = [];          
      getAllCalelements['vat'].push(result.rows.item(i).vat);
      getAllCalelements['GrossAmount'] = [];          
      getAllCalelements['GrossAmount'].push(result.rows.item(i).gamount);
      getAllCalelements['bookOrder'] = [];          
      getAllCalelements['bookOrder'].push(result.rows.item(i).bookorder);
  
  var json = JSON.stringify(getAllCalelements, undefined, 2);
  </code></pre>
  
  <p>But, We got JSON like this </p>
  
  <pre><code>{
    "totalamount": [19760.22],
    "discount": [ 7],
    "NetAmount": [ 18377],
    "vat": [ 8],
    "GrossAmount": [ 8],
    "bookOrder": [ "ABCANG00110"]
  }
  </code></pre>
  
  <p>And, We need JSON output like this </p>
  
  <pre><code>[
      {
          "totalamount": 19760.22,
          "discount": 7,
          "NetAmount": 18377,
          "vat": 8,
          "GrossAmount": 8,
          "bookOrder": "ABCANG00555"
      }
  ]    
  </code></pre>
  
  <p>I have tried but i am not getting desire output as mention above, I am getting JSON output. But We need JSON in the above format. All please guide me to get my desire output which is mention above, Thanks.</p>