code: public JsonObject optJsonObject(int index) {
          JsonElement el;
          try {
              el = get(index);
          } catch (JsonException e) {
              return null;
          }
          if (!el.isJsonObject()) {
              return null;
          }
          return el.asJsonObject();
      }
docs: Returns the value at {@code index} if it exists and is a {@code
  JsonObject}. Returns null otherwise.