x2js icon indicating copy to clipboard operation
x2js copied to clipboard

Text element order gets changed when doing "xml to json" and "json to xml"

Open sk8terboi87 opened this issue 8 years ago • 2 comments

x2js is great! But, facing the below issues... can you provide solution for it?

<tree>
    <node1> 
      textTextText 
      <subnode1> text1 </subnode1>
      <subnode2> text2 </subnode2>
    </node1>
</tree>

when doing xml to json

{
  "tree": {
    "node1": {
      "subnode1": "text1",
      "subnode2": "text2",
      "__text": "textTextText"
    }
  }
}
  1. And 'json to xml'
<tree>
	<node1>
		<subnode1>text1</subnode1>
		<subnode2>text2</subnode2>
                textTextText
        </node1>
</tree>

As you can see, the text nodes are pushed to last when reconverting.

sk8terboi87 avatar Nov 30 '17 07:11 sk8terboi87

Any luck with this thread?

dougn7 avatar Jul 09 '18 21:07 dougn7

<tree>
    <node1> 
      textTextText 
      <subnode1> text1 </subnode1>
      <subnode2> text2 </subnode2>
    </node1>
</tree>

may be converted to

{
  "tree": {
    "node1": {
      "#text": " \n      textTextText \n      ",
      "subnode1": " text1 ",
      "subnode2": " text2 "
    }
  },
  "#omit-xml-declaration": "yes"
}

javadev avatar Jun 28 '19 19:06 javadev