code: public Number optNumber(int index, Number defaultValue) {
          Object val = this.opt(index);
          if (JSONObject.NULL.equals(val)) {
              return defaultValue;
          }
          if (val instanceof Number){
              return (Number) val;
          }
          
          if (val instanceof String) {
              try {
                  return JSONObject.stringToNumber((String) val);
              } catch (Exception e) {
                  return defaultValue;
              }
          }
          return defaultValue;
      }
docs: Get an optional {@link Number} value associated with a key, or the default if there
  is no such key or if the value is not a number. If the value is a string,
  an attempt will be made to evaluate it as a number ({@link BigDecimal}). This method
  would be used in cases where type coercion of the number value is unwanted.
  
  @param index
  The index must be between 0 and length() - 1.
  @param defaultValue
  The default.
  @return An object which is the value.