Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Convert a Javascript object to a CSV file

DZone's Guide to

Convert a Javascript object to a CSV file

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

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;
}

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Published at DZone with permission of Gary Sieling, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}