xml2json-command
Version:
Convert an XML input to a JSON output, using xml-mapping
18 lines (13 loc) • 332 B
JavaScript
/*jshint node:true */
;
var xm = require('xml-mapping');
process.stdin.resume();
process.stdin.setEncoding('utf8');
var xml = '';
process.stdin.on('data', function (chunk) {
xml = xml + chunk;
});
process.stdin.on('end', function() {
var json = xm.load(xml);
console.log(JSON.stringify(json, null, '\t'));
});