code: public int getInt(String key) throws JSONException {
          Object object = this.get(key);
          try {
              return object instanceof Number ? ((Number) object).intValue()
                      : Integer.parseInt((String) object);
          } catch (Exception e) {
              throw new JSONException("JSONObject[" + quote(key)
                      + "] is not an int.");
          }
      }
docs: Get the int value associated with a key.
  
  @param key
  A key string.
  @return The integer value.
  @throws JSONException
  if the key is not found or if the value cannot be converted
  to an integer.