zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.71k stars 365 forks source link

an array no field how to use it #249

Closed tlhe closed 6 years ago

tlhe commented 6 years ago

eg:[1,2,3,4,'1,2,3,4']

juanjoDiaz commented 6 years ago

Can you clarify what you want to do?

That's not really a CSV. Or would you like to have a 1 column CSV with that data? Doesn't make much sense...

you could just do something like [1,2,3,4,'1,2,3,4'].reduce((csv, elem) => csv + '\n' + elem, '')

tlhe commented 6 years ago

an array like ['a','b','c','d,e'] i want use json2csv to get an csv file

juanjoDiaz commented 6 years ago

What would you expect from ['a','b','c','d,e']?

What should be the header? And what should be in each row?

tlhe commented 6 years ago

no header and each row is ['a','b','c','d,e'] and i want to get a,b,c,'d,e' in csv

juanjoDiaz commented 6 years ago

json2csv is intended to convert an array of objects not an array of strings (or dates, or numbers, or anything else ,for that matter)

Honestly, I don't see much value on what you propose. Sounds like something that you could achieve with basic JS as I said above [1,2,3,4,'1,2,3,4'].reduce((csv, elem) => csv + '\n' + elem, '')

I'll close this since I don't think that it will be implemented in the library. Feel free to argue otherwise.