mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 03:06:03 +08:00
updates the getNumber/optNumber to not return invalid Doubles
This commit is contained in:
@@ -738,7 +738,11 @@ public class JSONArray implements Iterable<Object> {
|
||||
return BigInteger.valueOf(((Number) val).longValue());
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(val.toString()).toBigInteger();
|
||||
final String valStr = val.toString();
|
||||
if(JSONObject.isDecimalNotation(valStr)) {
|
||||
return new BigDecimal(valStr).toBigInteger();
|
||||
}
|
||||
return new BigInteger(valStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user