JSON converts hexadecimal to decimal
in
Core Library Questions
•
6 months ago
If I am running the following java code with json version 20080701:
String xmlString = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><response><code>0x02FE0921</code></response></soap:Body></soap:Envelope>";
JSONObject json = XML.toJSONObject(xmlString);
then I get a JSONObject which looks like this:
{"soap:Envelope":{"soap:Body":{"response":{"code":"0x02FE0921"}},"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}}
but if I am using json version 20090211 then the same code will get me a JSONObject looking like this:
{"soap:Envelope":{"soap:Body":{"response":{"code":50202913}},"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}}
Notice how the "code" is now in decimal (50202913) rather then remaining in hexadecimal (0x02FE0921).
It would appear that in this latest version of the JSON jar they don't assume a String as often as they use to...
Can this be changed? Can we somehow get the same behavior with the 2009011 version as we did with the 20080701 version?
String xmlString = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><response><code>0x02FE0921</code></response></soap:Body></soap:Envelope>";
JSONObject json = XML.toJSONObject(xmlString);
then I get a JSONObject which looks like this:
{"soap:Envelope":{"soap:Body":{"response":{"code":"0x02FE0921"}},"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}}
but if I am using json version 20090211 then the same code will get me a JSONObject looking like this:
{"soap:Envelope":{"soap:Body":{"response":{"code":50202913}},"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}}
Notice how the "code" is now in decimal (50202913) rather then remaining in hexadecimal (0x02FE0921).
It would appear that in this latest version of the JSON jar they don't assume a String as often as they use to...
Can this be changed? Can we somehow get the same behavior with the 2009011 version as we did with the 20080701 version?
1