xml-json-format
v1.0.8
Published
Convert xml string to neatly formatted JSON object
Downloads
445
Maintainers
Readme
xml-json-format
Installation
USAGE
Run npm install --save xml-json-format
const toJSON = require('xml-json-format')
const xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
const jsonResult = toJSON(xml);
console.log(jsonResult);
/* expected: {
"_declaration": {
"_attributes": {
"version": "1.0",
"encoding": "utf-8"
}
},
"note": {
"_attributes": {
"importance": "high",
"logged": "true"
},
"title": "Happy",
"todo": [
"Work",
"Play"
]
}
} */