I\'m currently learning how to parse a JSON object to a CSV file using the json2csv node module. Have never worked with JSON before, so this is all new to me.
My JSO
I don't know about you guys, but i like small packages that just work as expected without a lot of extra configuration, try using jsonexport, works really well with objects, arrays, .. and its fast!
Install
npm i --save jsonexport
Usage
const jsonexport = require('jsonexport');
const fs = require('fs');
jsonexport({
"car":[
{
"name":"Audi",
"price":"40000",
"color":"blue"
}
]
}, function(err, csv) {
if (err) return console.error(err);
fs.writeFile('cars.csv', csv, function(err) {
if (err) return console.error(err);
console.log('cars.csv saved');
});
});
https://github.com/kauegimenes/jsonexport