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
const { Parser } = require('json2csv');
let myCars = {
"car":
{
"name": ["Audi"],
"price": ["40000"],
"color": ["blue"]
}
};
let fields = ["car.name", "car.price", "car.color"];
const parser = new Parser({
fields,
unwind: ["car.name", "car.price", "car.color"]
});
const csv = parser.parse(myCars);
console.log('output',csv);
will output to console