code: public BigDecimal getBigDecimal (int index) throws JSONException {
          Object object = this.get(index);
          BigDecimal val = JSONObject.objectToBigDecimal(object, null);
          if(val == null) {
              throw new JSONException("JSONArray[" + index +
                      "] could not convert to BigDecimal ("+ object + ").");
          }
          return val;
      }
docs: Get the BigDecimal value associated with an index. If the value is float
  or double, the the {@link BigDecimal#BigDecimal(double)} constructor
  will be used. See notes on the constructor for conversion issues that
  may arise.
  
  @param index
  The index must be between 0 and length() - 1.
  @return The value.
  @throws JSONException
  If the key is not found or if the value cannot be converted
  to a BigDecimal.