Skip to content

Commit

Permalink
preserve newlines in cells
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuentello committed May 20, 2016
1 parent c5587d5 commit c2b0f81
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/json2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ function createColumnContent(params, str) {
//JSON.stringify('\\') results in a string with two backslash
//characters in it. I.e. '\\\\'.
stringifiedElement = stringifiedElement.replace(/\\\\/g, '\\');


// preserve newlines
stringifiedElement = stringifiedElement.split('\\n').join('\n')

if (params.excelStrings && typeof val === 'string') {
stringifiedElement = '"="' + stringifiedElement + '""';
}
Expand Down

0 comments on commit c2b0f81

Please sign in to comment.