gafasmill gafasmill - 3 months ago 37
jQuery Question

Javascript / Json convert data format

I am reading data from a page which looks like this:


In order to get the charts working in my page I need to convert it to something like this:


What would be the best way to convert this data, as this data can increase in size.


You can use map() and Object.keys() to do this

var obj = {"cars":0,"bikes":"1"};
var result = Object.keys(obj).map(function(e) {
  return {key: e, value: obj[e]}