code: public JsonObject toJson() {
      JsonObject body = new JsonObject();
      body.add(JsonRpcProtocol.ID, id());
  
      if (isError()) {
        body.add(JsonRpcProtocol.ERROR, error().toJson());
      } else {
        body.add(JsonRpcProtocol.RESULT, result());
      }
      return body;
    }
docs: Generates the JSON representation of this response.