title: json to csv comma issue javascript
body: <p>I would like to know how to convert the json to csv in javascript,
  Below code works, but in scenario example if header <code>details</code> has values seperated by comma
  <code>service, finance</code>, then value get shifted to next columns</p>
  
  <pre><code>  convertToCSV(objArray) {
      var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
      var str = '';
      for (var i = 0; i &lt; array.length; i++) {
          var line = '';
          for (var index in array[i]) {
              if (line != '') line += ','
  
              line += array[i][index];
          }
          console.log(str, line);
          str += line + '\r\n';
      }
      return str;
  }
  
    exportCSV =(tabledata) =&gt;{
      const items  = tabledata;
      const fileTitle = "Sample";
      // Convert Object to JSON
      var jsonObject = JSON.stringify(items);
      var csv = this.convertToCSV(jsonObject);
      console.log(csv);
      var exportedFilenmae = fileTitle + '.csv' || 'export.csv';
      var blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
      if (navigator.msSaveBlob) { // IE 10+
          navigator.msSaveBlob(blob, Sample Report);
      } else {
          var link = document.createElement("a");
          if (link.download !== undefined) { // feature detection
              // Browsers that support HTML5 download attribute
              var url = URL.createObjectURL(blob);
              link.setAttribute("href", url);
              link.setAttribute("download", "Sample Report");
              link.style.visibility = 'hidden';
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link);
          }
      }
  }
  
  &lt;button onClick="exportCSV(tabledata)"&gt;Download as CSV&lt;/button&gt;
  
  
  const tabledata = [
    ["id", "details", "status"],
    [1, "service,finance", "Active"],
    [2, "service", "Inactive"],
    [3, "member,service,finance", "Active"]
  ]
  </code></pre>
  
  <p>Expected Output:
  <a href="https://i.stack.imgur.com/XSz1M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSz1M.png" alt="enter image description here"></a></p>