1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00
This commit is contained in:
stleary 2015-07-06 22:20:19 -05:00
parent 474f285cc8
commit 410afaff14

View file

@ -531,6 +531,44 @@ public class JSONArray implements Iterable<Object> {
} }
} }
/**
* Get the optional BigInteger value associated with an index. The
* defaultValue is returned if there is no value for the index, or if the
* value is not a number and cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public BigInteger optBigInteger(int index, BigInteger defaultValue) {
try {
return this.getBigInteger(index);
} catch (Exception e) {
return defaultValue;
}
}
/**
* Get the optional BigDecimal value associated with an index. The
* defaultValue is returned if there is no value for the index, or if the
* value is not a number and cannot be converted to a number.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default value.
* @return The value.
*/
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
try {
return this.getBigDecimal(index);
} catch (Exception e) {
return defaultValue;
}
}
/** /**
* Get the optional JSONArray associated with an index. * Get the optional JSONArray associated with an index.
* *