title: How to change json data format from array to array of objects with javascript?
body: <p>I am trying to load data into <code>ag-grid</code> so I got the json data like this format:</p>
  
  <pre><code>{"my_data":{"labels":[1,2,3,...], "idx":["idx1", "idx2", ...]}}
  </code></pre>
  
  <p>I need it to be like this to pass it to the grid:</p>
  
  <pre><code>{"my_data":[{"labels": 1}, {"labels": 2}, ..., {"idx":"idx1"}, {"idx":"idx2"}, ...}]
  </code></pre>
  
  <p>Is there a fast way to do it this format or I have to loop through the data using <code>reduce</code> or <code>map</code> ?</p>
  
  <p>desired format example: <a href="https://www.ag-grid.com/sample-data/monthlySales.json" rel="nofollow noreferrer">https://www.ag-grid.com/sample-data/monthlySales.json</a></p>
  
  <p>I tried to load the data like this</p>
  
  <pre><code>var obj = $.parseJSON(JSON.stringify(data));
  gridOptions.api.setRowData(obj.mydata.labels);
  </code></pre>