def METHOD_NAME(self, stream: IO, encoding: str = None) -> None:  # type: ignore[override]
    res: Dict[str, Any] = {}
    if self.result.type == "ASK":
        res["head"] = {}
        res["boolean"] = self.result.askAnswer
    else:
        # select
        res["results"] = {}
        res["head"] = {}
        res["head"]["vars"] = self.result.vars
        res["results"]["bindings"] = [
            self._bindingToJSON(x) for x in self.result.bindings
        ]
    r = json.dumps(res, allow_nan=False, ensure_ascii=False)
    if encoding is not None:
        stream.write(r.encode(encoding))
    else:
        stream.write(r)