Created
May 2, 2017 03:22
-
-
Save freshyill/8c3fe8513c3ec2e6346a4c8afbb6cdf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const convert = require('xml2json'); | |
const xmlDir = 'final_xml'; | |
fs.readdir(xmlDir, (err, xmlList) => { | |
for (let xmlFile of xmlList) { | |
fs.readFile(xmlDir + "/" + xmlFile, "utf-8", (err, fileContents) => { | |
if (err) throw err; | |
const newJson = convert.toJson(fileContents); | |
const jsonFileName = xmlFile.replace('.xml','.json'); | |
fs.writeFile("issueJson/" + jsonFileName, newJson, function (err) { | |
if (err) { | |
console.log("Something went wrong!"); | |
} else { | |
console.log("Created " + jsonFileName) | |
} | |
}) | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment