How can I convert json object with array to csv?
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4.3k
- Forks
- 299
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 1
Description
Describe the bug
I've installed csv-stringify via npm install.
To Reproduce
import { stringify as csvStringify } from "csv-stringify/sync";
jsonString = `{"test":["1","2"]}`
jsonData = JSON.parse(jsonString);
console.log(csvStringify([jsonData], { delimiter: ",", header: true }));
Additional context
I've expecting result as below.
test
1
2
But the result came as below.
test
"[""1"",""2""]"
Thanks for your help!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named in the issue. Start by reproducing the csv-stringify/sync example and read the stringification documentation for array-valued fields; done should be a confirmed explanation or a clearly scoped change with a test for the expected CSV output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100