adaltas / adaltas/node-csv

How can I convert json object with array to csv?

Open
#412 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.