public int getInt(String key) throws JSONException { JSONValue v = get(key); if (v == null) throw new JSONException(JSONErrorCode.KeyIsNotFound, key); JSONNumber n = v.getJSONNumber(); if (n == null) throw new JSONException(JSONErrorCode.NotAJSONNumber, v.toString()); return n.getIntValue(); }