I want to parse some JSON data in uint32 and uint64 format that are sent as numbers (without quotes), and then use them in java.
I found out that I can store them as unsigned integers via the parseUnsignedInt(String) method, but the problem is that I cannot get the json value as a string, because it's lacking quotes. If I parse it as an int, the value returned is wrong before I have the chance to convert it.
Example:
// data is a JSONObject containing: {"number" : 4294967294}
...
System.out.println(data.getInt("number"));
// returns: -10001
System.out.println(Integer.parseUnsignedInt(data.getString("number")));
// returns: JSONObject["number"] not a string.
System.out.println(Integer.parseUnsignedInt(Integer.toString(data.getInt("number"))));
// returns: Illegal leading minus sign on unsigned string -10001.
Is there a way to extract the value from the json object as a string (or any other way that doesn't ruin it)?