title: How to add data dynamically in JSON object
body: <p>Sample code</p>
  
  <pre><code>var mydata = [ {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}];
  </code></pre>
  
  <p>I have to get output something like above, have to add dynamically columns and its value to mydata.</p>
  
  <p>I am trying to do something like this but its not working for me.</p>
  
  <pre><code>var mydata = [];
  for (var r = 0; r &lt; dataTable.getNumberOfRows(); r++) {
    var items = "";
    var y ="";
     for (var c = 0; c &lt; dataTable.getNumberOfColumns(); c++) {
       items += '"'+dataTable.getColumnLabel(c)+'":'+dataTable.getValue(r, c)
        if(c!=dataTable.getNumberOfColumns()-1){
          items += ",";
        }
     }
     y = "{"+items+"}";
     mydata.push(y);
  }
  </code></pre>
  
  <p>above code doesnt works for me. any other way for it</p>