Skip to content

Commit

Permalink
Fixed 'JSON to CSV' handling of complex structures. Closes #637
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed Feb 16, 2021
1 parent 59c1c45 commit 3a9bdc5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/operations/JSONToCSV.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ class JSONToCSV extends Operation {
*/
escapeCellContents(data) {
if (typeof data === "number") data = data.toString();
if (typeof data !== "string") data = JSON.stringify(data);

// Double quotes should be doubled up
data = data.replace(/"/g, '""');

// If the cell contains a cell or row delimiter or a double quote, it mut be enclosed in double quotes
// If the cell contains a cell or row delimiter or a double quote, it must be enclosed in double quotes
if (
data.indexOf(this.cellDelim) >= 0 ||
data.indexOf(this.rowDelim) >= 0 ||
Expand Down

0 comments on commit 3a9bdc5

Please sign in to comment.