Skip to content

Commit

Permalink
switches back to using get so we don't have as much custom code
Browse files Browse the repository at this point in the history
  • Loading branch information
John J. Aylward committed Oct 2, 2018
1 parent c2038b8 commit cdb3bfb
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,13 @@ public boolean getBoolean(String key) throws JSONException {
* be converted to BigInteger.
*/
public BigInteger getBigInteger(String key) throws JSONException {
Object val = this.opt(key);
if (val == null) {
throw new JSONException("JSONObject[" + quote(key) + "] not found.");
}
BigInteger ret = objectToBigInteger(val, null);
Object object = this.get(key);
BigInteger ret = objectToBigInteger(object, null);
if (ret != null) {
return ret;
}
throw new JSONException("JSONObject[" + quote(key)
+ "] could not be converted to BigInteger (" + val + ").");
+ "] could not be converted to BigInteger (" + object + ").");
}

/**
Expand All @@ -662,16 +659,13 @@ public BigInteger getBigInteger(String key) throws JSONException {
* cannot be converted to BigDecimal.
*/
public BigDecimal getBigDecimal(String key) throws JSONException {
Object val = this.opt(key);
if (val == null) {
throw new JSONException("JSONObject[" + quote(key) + "] not found.");
}
BigDecimal ret = objectToBigDecimal(val, null);
Object object = this.get(key);
BigDecimal ret = objectToBigDecimal(object, null);
if (ret != null) {
return ret;
}
throw new JSONException("JSONObject[" + quote(key)
+ "] could not be converted to BigDecimal (" + val + ").");
+ "] could not be converted to BigDecimal (" + object + ").");
}

/**
Expand Down

0 comments on commit cdb3bfb

Please sign in to comment.