I want to parse json loaded from file const notCleanData = JSON.parse(fs.readFileSync('db.json'));
to be able to export to CSV using json2csv. I loaded the file and learn how to export, but I can't figure out how to clean JSON from unnecessary part of JSON, cos it's making CSV to be exported in a wrong way. Instead having data from array in separate columns, I get all data under one column with "group" as header. How to convert A.json to B.json for exporting clean JSON to CSV?
A.json
{
"group" : [
{
"A" : "1",
"B" : "2"
},
{
"A" : "3",
"B" : "4"
}
],
"profile" : {
"C" : "5"
}
}
B.json
{
"A" : "1",
"B" : "2"
},
{
"A" : "3",
"B" : "4"
}
In short: How to extract data only from "group" and add it to variable?