Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of newline in string literal potential issue #6

Closed
TomShriner opened this issue Jun 25, 2016 · 1 comment
Closed

Handling of newline in string literal potential issue #6

TomShriner opened this issue Jun 25, 2016 · 1 comment

Comments

@TomShriner
Copy link

TomShriner commented Jun 25, 2016

I saw an issue where one of my json entries contained a newline - example:

"q10":"blahblahblahe\n",

which seems to not get handled properly. Could I be missing an option to handle this or is there an issue with the character embedded in the string literal (or perhaps my json is not properly escaped - I retrieve via an external API which may be violating the json spec - but it looks right).

It should be valid in JSON to have a string containing a newline.

@kaue
Copy link
Owner

kaue commented Sep 23, 2016

@TomShriner You could use the handleString option if you want to remove linebreaks from all strings, but i think another option would be to add the textDelimiter in the CSV when a linebreak is detected (needs to be tested) https://github.com/Cnova/jsonexport/blob/master/lib/index.js#L122

var options = {
    handleString: (string, name) => string.replace(/\n/g, '')
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants