MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / send_json_bytes

Method send_json_bytes

aiohttp/web_ws.py:498–510  ·  view source on GitHub ↗

Send JSON data using a bytes-returning encoder as a binary frame. Use this when your JSON encoder (like orjson) returns bytes instead of str, avoiding the encode/decode overhead.

(
        self,
        data: Any,
        compress: int | None = None,
        *,
        dumps: JSONBytesEncoder,
    )

Source from the content-addressed store, hash-verified

496 await self.send_str(dumps(data), compress=compress)
497
498 async def send_json_bytes(
499 self,
500 data: Any,
501 compress: int | None = None,
502 *,
503 dumps: JSONBytesEncoder,
504 ) -> None:
505 """Send JSON data using a bytes-returning encoder as a binary frame.
506
507 Use this when your JSON encoder (like orjson) returns bytes
508 instead of str, avoiding the encode/decode overhead.
509 """
510 await self.send_bytes(dumps(data), compress=compress)
511
512 async def write_eof(self) -> None: # type: ignore[override]
513 if self._eof_sent:

Callers 6

handlerFunction · 0.95

Calls 2

send_bytesMethod · 0.95
dumpsFunction · 0.85

Tested by 6

handlerFunction · 0.76