Wednesday, 26 April 2017

Using fs.writefile to create an array of objects

I am parsing some xml and creating json objects from it.

I would like each json object to be inside an array within the file that is created by fs.writefile. Currently the output is into json objects, and I need the output to be arrays containing json objects......

Below is the code where i am creating each new json file from the xml.

Any help appreciated!

files.forEach(function (filename){
fs.writeFile('./seeds/' + filename +'.json', json, (err) => {
if (err) throw err;
console.log("FILE SAVED")
}}

Thanks



via ste

No comments:

Post a Comment