code: public JSONObject optJSONObject(String key) {
          Object object = this.opt(key);
          return object instanceof JSONObject ? (JSONObject) object : null;
      }
docs: Get an optional JSONObject associated with a key. It returns null if
  there is no such key, or if its value is not a JSONObject.
  
  @param key
  A key string.
  @return A JSONObject which is the value.