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

CSV to JSON is incorrectly tranformed if there is a field that starts with a break line. #265

Closed
4 of 5 tasks
AndrzejKmicic opened this issue Sep 25, 2024 · 6 comments
Closed
4 of 5 tasks

Comments

@AndrzejKmicic
Copy link

AndrzejKmicic commented Sep 25, 2024

Background Information

  • Module Version:
  • Node/Browser Version:

The issue I'm reporting is with:

  • json2csv
  • csv2json

I have...

  • searched to see if an issue has already been reported.
  • verified that my JSON/CSV data is valid (using something like http://jsonlint.com or https://csvlint.io/).
  • tried upgrading to the latest version of json-2-csv (since the issue may already be fixed).

Expected Behavior

CSV to JSON is correctly tranformed if there is a field that starts with a break line.

{"id":1,"name":"John Doe","age":29,"city":"New York"}
{"id":2,"name":"Jane Smith","age":34,"city":"\n Los Angeles"}
{"id":3,"name":"Emily Davis","age":22,"city":"Chicago"}
{"id":4,"name":"Michael Brown","age":40,"city":"Houston"}

Actual Behavior

CSV to JSON is incorrectly tranformed if there is a field that starts with a break line.

{"id":1,"name":"John Doe","age":29,"city":"New York"}
{"id":2,"name":"Jane Smith","age":"34,\""}
{"id":" Los Angeles\""}
{"id":3,"name":"Emily Davis","age":22,"city":"Chicago"}
{"id":4,"name":"Michael Brown","age":40,"city":"Houston"}

Data Sample

CSV:

id,name,age,city\n1,John Doe,29,New York\n2,Jane Smith,34,"\n Los Angeles"\n3,Emily Davis,22,Chicago\n4,Michael Brown,40,Houston

Code Example

Stackblitz

@mattrobinson10
Copy link

I'm also experiencing this issue. It looks like it might have previously been fixed here #240, I wonder if a regression has been introduced at some point?

@mattrobinson10
Copy link

I have checked the release generated from #240 , and the issue is present there as well, so I don't think this issue is a regression after all.

@mrodrig
Copy link
Owner

mrodrig commented Nov 21, 2024

Thanks for reporting this @AndrzejKmicic and for testing it against the release from #240 @mattrobinson10. Sorry for the delay in addressing this - I had some personal commitments that needed my full attention as a family member wasn't well. I've started looking into this issue and think I have a general idea as to why this is happening. I'll keep you updated when I have a solution. Thanks again for your understanding.

@mattrobinson10
Copy link

No problem at all @mrodrig, sorry to hear that a family member wasn't well I hope they are feeling better now. If I can help with anything let me know!

mrodrig added a commit that referenced this issue Nov 24, 2024
@mrodrig mrodrig mentioned this issue Nov 24, 2024
2 tasks
mrodrig added a commit that referenced this issue Nov 24, 2024
publishes the fix for #265
@mrodrig
Copy link
Owner

mrodrig commented Nov 25, 2024

This should be resolved in the latest release (5.5.7). Please let me know if you run into any other issues and thanks again for your help tracking this down. 🙂

@mattrobinson10
Copy link

Thanks for the super quick fix! 🙌

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

No branches or pull requests

3 participants