Reputation: 785
Was looking at a few questions in SO for a good solution for XML to JSON convertors. I Chanced upon this : Convert xml to json with Java This seemed to work fine for almost all of our scenarios but for the issue below! I noticed whenever I we have an XML such as this (zero followed by a number)
<a>011</a>
this seems to be getting formatted to
{a:9}
However this seems to work fine
<a>11</a>
Whcih gets formatted to
{a:11}
This is the simple code I am using:
String sXML = "<a>011</a>";
JSONObject xmlJSONObj = XML.toJSONObject(sXML);
Any pointers?
Upvotes: 0
Views: 94
Reputation: 2832
Looks like it thinks it's an octal value, which is why you get 9, see the following article which has a similar problem:
Upvotes: 2