title: Convert JSON object to CSV and save it to a file
body: <p>A user press a button and it executes a SQL query to my database using NodeJS and the result is a JSON object (one array with objects). After that the result must be saved in a file (the user need the file).</p>
  
  <p>The problem: it can't be a JSON. The format is only the values separated by the simbol "<strong>;</strong>" and one object per line.</p>
  
  <p>Example of the file's content that I need to create (it is like a CSV):</p>
  
  <pre><code>1;tree;green
  2;car;red
  3;Robert's house;white
  </code></pre>
  
  <p>This result query has around 18000 rows. It is big.</p>
  
  <p>I am using the <strong>replace method</strong> but I have problems with values with the simbol <strong>'</strong> like in <strong>Robert's house</strong> because the console interpreted as a begining of a string.</p>
  
  <p>Then in the client side I use:</p>
  
  <pre><code>$window.open('data:text/csv,' + encodeURIComponent(myString));
  </code></pre>
  
  <p>And here the simbols <strong>'</strong> start the problem.</p>
  
  <p>I would like to know how to transform a JSON to that format (under NodeJS) and how to create the file.</p>