code: public JSONObject getJSONObject(int index) throws JSONException {
      Object o = get(index);
      if (o instanceof JSONObject) {
        return (JSONObject) o;
      }
      throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
    }
docs: Get the JSONObject associated with an index.
  
  @param index
  subscript
  @return A JSONObject value.
  @throws JSONException
  If there is no value for the index or if the value is not a JSONObject