title: Convert json from URL to CSV for D3.js
body: <p>I am reading in json from a web API which json encodes data from a mysql database. The URL from the web API returns json as such: </p>
  
  <pre><code>{"result":[{"name":"joe","how_many":"5"},{"name":"chris","how_many":"10"},{"name":"steven","how_many":"5"},{"name":"melissa","how_many":"2"}]}
  </code></pre>
  
  <p>I am working with a D3.js graph that requires a CSV file format as such: </p>
  
  <pre><code>d3.csv('data.csv', function(error, data){
  // do D3 stuff here 
  } 
  </code></pre>
  
  <p>I am trying to convert the json response from the web API into something that the CSV-dependent D3 graph can interpret.  Does the CSV need to be a file on the server and therefore I must convert the JSON response to a CSV file using say some PHP server side script? Or would it make more sense to read in the JSON as a string object in javascript...then convert that to a 'CSV String(?)' and allow D3 to read the newly created CSV String?</p>
  
  <p>I can use AJAX to read in the JSON from the url and get the JSON using get.JSON... but how can I then make this available as CSV format for D3?</p>