My JSON value has a value with hyphen like database-name.
I wanted to replace the value of the database-name using below code
result.databases.database-name = 'ArangoDB';
But it is showing error, How to call the JSON value when the value is having hyphen
Here is a code
const fs = require("fs");
const xml2js = require('xml2js');
fs.readFile("databases.xml", "utf-8", (err, data) => {
if (err) {
throw err;
}
xml2js.parseString(data, (err, result) => {
if (err) {
throw err;
}
result.databases.database-name = 'ArangoDB';
const builder = new xml2js.Builder();
const xml = builder.buildObject(result);
fs.writeFile('new-databases.xml', xml, (err) => {
if (err) {
throw err;
}
console.log(`Updated XML is written to a new file.`);
});
});
});