xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

not reversible json->xml->json

Open smandlavdiya opened this issue 4 years ago • 2 comments
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 ?

smandlavdiya avatar Feb 16 '21 08:02 smandlavdiya

{compact: true} is not reversible. Explained here: https://github.com/nashwaan/xml-js#compact-vs-non-compact

vjpr avatar Sep 05 '21 01:09 vjpr

{
   "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

javadev avatar May 02 '23 06:05 javadev