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

Field in CSV it turned into an object unexpectedly. #254

Closed
1 of 2 tasks
hydrohiester opened this issue Mar 15, 2024 · 2 comments
Closed
1 of 2 tasks

Field in CSV it turned into an object unexpectedly. #254

hydrohiester opened this issue Mar 15, 2024 · 2 comments
Assignees
Labels
bug csv2json CSV to JSON

Comments

@hydrohiester
Copy link

Background Information

  • Module Version: 5.5.0
  • Node/Browser Version: 20.10.0

The issue I'm reporting is with:

  • json2csv
  • [X ] csv2json

I have...

  • [ X] searched to see if an issue has already been reported.
  • [ X ] 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 Header: 'Account No.'
CSV Field: '01-1800-00'

I expect to get:
{'Account No.': '01-1800-00'}

Actual Behavior

It gets converted to
{ 'Account No': { '': '01-1800-00' }}

If I remove the period in "Account No." it works correctly. Is a period not allowed in a heading?

I tried setting excelBOM to true, but it didn't make a difference.

@mrodrig
Copy link
Owner

mrodrig commented Mar 15, 2024

Hi @hydrohiester, thanks for reporting this. That definitely sounds like a bug to me. My guess is the parsing logic needs an update to account for that possibility, since it's completely valid.

I'm currently traveling with no access to my typical development machine, but should hopefully be able to take a closer look at this either later this weekend or early next week. I'll keep you posted.

@mrodrig mrodrig self-assigned this Mar 18, 2024
@mrodrig mrodrig added bug csv2json CSV to JSON labels Mar 18, 2024
mrodrig added a commit to mrodrig/doc-path that referenced this issue Mar 21, 2024
Example:

setPath({}, 'Account No.', '01');

/**
results in:
{ 'Account No': { '': '01-1800-00' } }
*/
However, the '' key in the sub-doc should not be generated.

Identified from report in mrodrig/json-2-csv#254

Fixes #39
mrodrig added a commit that referenced this issue Mar 21, 2024
mrodrig added a commit that referenced this issue Mar 21, 2024
Resolve #254 by updating doc-path to patched version
@mrodrig
Copy link
Owner

mrodrig commented Mar 21, 2024

Thanks again for reporting this @hydrohiester. It ended up being a different issue with the logic in my doc-path package rather than what I expected, but it should be resolved now in version 5.5.1 that I just published.

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

No branches or pull requests

2 participants