mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
updates the getNumber/optNumber to not return invalid Doubles
This commit is contained in:
parent
a7f8ff24df
commit
849b392c01
2 changed files with 54 additions and 30 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue