mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05: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