code: public Number getNumber(String key) throws JSONException {
          Object object = this.get(key);
          try {
              if (object instanceof Number) {
                  return (Number)object;
              }
              return stringToNumber(object.toString());
          } catch (Exception e) {
              throw new JSONException("JSONObject[" + quote(key)
                      + "] is not a number.", e);
          }
      }
docs: Get the Number value associated with a key.
  
  @param key
  A key string.
  @return The numeric value.
  @throws JSONException
  if the key is not found or if the value is not a Number
  object and cannot be converted to a number.