Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readFile(__dirname + '/example.xml', function(err, data) {
if (err) throw err;
// parsing the new xml data and converting them into json file
var json = parser.toJson(data);
// send the new data to the client
socket.volatile.emit('notification', json);
});
});
exports.fromString = function(wadlString, options) {
/* Remove XML header as xml2json is not able to parse it */
wadlString = wadlString.replace(/<\?[^<]*\?>/g, "");
var wadlJson = parser.toJson(wadlString, {
object: true,
arrayNotation: true
});
return wadl2json.fromJSON(wadlJson, options);
};
request.post(req, function (err, res, body) {
if (err) return callback(err);
var json = parser.toJson(body, { object: true });
var entries = json.feed.entry;
// Google response for a single cell isn't an array
if (queries.length === 1) entries = [entries];
var cells = entries.map(function (entry) {
var cell = entry['gs:cell'];
return {
row: cell.row,
column: cell.col,
value: cell.inputValue,
numeric: cell.numericValue,
text: cell.$t
};
});
return callback(null, cells);
});
return this;
}, (err, rsp, xml) => {
if (err) {
tasks.forEach(x => x.callback(err));
return next(err);
}
if (rsp.statusCode !== 200) {
err = new Error("Request returned " + rsp.statusCode);
tasks.forEach(x => x.callback(err));
return next(err);
}
const body = xml2json.toJson(xml, {
arrayNotation: true, // ensure we get consistent results regardless of the number of results
// returned
object: true,
});
const versions = body.osm[0][OSM_ENTITY_TYPES[entityType]].reduce((obj, entity) => {
obj[entity.id] = entity.version;
return obj;
}, {});
tasks.forEach(x => {
if (versions[x.id]) {
return x.callback(null, versions[x.id]);
}
const doCheck = (xmlFile, minNumber) => {
const xml = fs.readFileSync(xmlFile, 'utf8')
const info = JSON.parse(xml2json.toJson(xml))
const number = Number(info.testsuites.tests)
console.info(`Executed ${number} tests`)
process.exit(number >= minNumber ? 0 : 2)
}
parseFile() {
let results = false;
try {
results = xmlParser.toJson(this.fileContent);
results = JSON.parse(results);
} catch(e) {
console.log('An error occurred:', e);
return false;
}
this.parsedContent = results;
return true;
}
request(url, function (error, response, html) {
var json = parser.toJson(url); //returns a string containing the JSON structure by default
console.log(json);
res.send('Check your console!');
});
});
.on("end", function () {
try {
var json = parser.toJson(rss);
var jsonObject = JSON.parse(json);
res.write(json);
res.end();
} catch (e) {
console.log(e);
}
});
;
fs.readFile('dumps/' + wiki + '.xml', function(err, data) {
var xml = data;
console.log ('xml size:', data.length);
var json = parser.toJson(xml, { sanitize: false, trim: false });
console.log('json size:', json.length);
var js = "var jsondump = " + json;
fs.writeFile('dumps/' + wiki + '.js', js, function(err) {
if (err) {
throw err;
}
console.log('saved');
});
});
.then(response => {
console.log("todo response:")
eyes.inspect(response.data)
if (format === "xml") {
const result = JSON.parse(parser.toJson(response.data))
return result.projects.project
} else {
return response.data
}
})
.catch(error => {