xml-js
xml-js copied to clipboard
not reversible json->xml->json
trafficstars
hi there
i tried running below snippet
var xmlJs = require("xml-js") var json = {"a":[{"t":1}]} var options = {compact: true, spaces: 4}; result1 = xmlJs.json2xml(json, options); result2 = xmlJs.xml2json(result1, options); console.log(result1, '\n', result2);
and the result is not identical to sources can you please help me do that ?
{compact: true} is not reversible. Explained here: https://github.com/nashwaan/xml-js#compact-vs-non-compact
{
"a": [
{
"t": 1
}
]
}
may be converted to xml
<?xml version="1.0" encoding="UTF-8"?>
<a array="true">
<t number="true">1</t>
</a>
https://xmltojson.github.io/json-to-xml.html