I want to convert a json array of elements to csv in node.js. I've found some module doing that like json2csv or json-csv but they are not complete. For example json2csv only support a flat structure where fields are direct children of the json root and also the schema should be the same for all json objects.
In my case, I want that.
I suppose that i've a json array of objects like that:
[{
"libelle" : "Projet 1",
"beneficiaire" : "Mr Leroy",
"nature" : "Diagnostics patrimoniaux",
"phasage" : "GLOBAL",
"budget": [
{"status": "BROUILLON"}
],
"status" : "BROUILLON"
},
{
"libelle" : "Projet 2",
"beneficiaire" : "Mr Leroy",
"nature" : "Diagnostics patrimoniaux",
"phasage" : "GLOBAL",
"status" : "BROUILLON"
}]
and i want to convert it to csv like that:
"libelle","beneficiaire","nature","phasage","budget[0].status","status" "Projet 1","Mr Leroy","Diagnostics patrimoniaux","GLOBAL","BROUILLON","BROUILLON" "Projet 2","Mr Leroy","Diagnostics patrimoniaux","GLOBAL",,"BROUILLON"
I'm looking for a good and complete node module for doing that. If it doesn't exist, I will do it myself i think so.