Gary Sieling

Convert a Javascript object to a CSV file

The following will, print out a Javascript object as a string – edit as you see fit.

function csv(placesQueue) {
  var str = 'latitude,longitude\n'; // column headers
  $.each(placesQueue, function(idx, x) {
    str = str + x.geometry.location.jb + "," + x.geometry.location.kb + "\n"
  });
  return str;
}
Exit mobile version