我有JSON将数字转换为不同的格式,我无法转换回我需要的实际数字
new JSONObject("{ \"trxId\": 1611041100656111100142000000000497}\");
Log.e(jsonObj.getString("trxId")
输出:
1.6110411006561111EE
我得到了这个trxId以及更多细节,这个ID将用于与服务器的进一步API调用。
答案 0 :(得分:0)
You will need to use BigDecimal class here and may be use doubleValue()
method for that. Use something similar to the following:
String requiredNumber = new BigDecimal(stringRepresentationOfYourNumber).doubleValue() + "";
That way you can get the full number instead of the scientific notation.
See here