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 6661986
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
10 changes: 2 additions & 8 deletions JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,7 @@ public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONExcep
* to a BigDecimal.
*/
public BigDecimal getBigDecimal (int index) throws JSONException {
Object object = this.opt(index);
if (object == null) {
throw new JSONException("JSONArray[" + index + "] not found.");
}
Object object = this.get(index);
BigDecimal val = JSONObject.objectToBigDecimal(object, null);
if(val == null) {
throw new JSONException("JSONArray[" + index +
Expand All @@ -370,10 +367,7 @@ public BigDecimal getBigDecimal (int index) throws JSONException {
* to a BigInteger.
*/
public BigInteger getBigInteger (int index) throws JSONException {
Object object = this.opt(index);
if (object == null) {
throw new JSONException("JSONArray[" + index + "] not found.");
}
Object object = this.get(index);
BigInteger val = JSONObject.objectToBigInteger(object, null);
if(val == null) {
throw new JSONException("JSONArray[" + index +
Expand Down
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 6661986

Please sign in to comment.