MCPcopy Create free account
hub / github.com/encode/starlette / send_json

Method send_json

starlette/testclient.py:172–177  ·  view source on GitHub ↗
(self, data: Any, mode: Literal["text", "binary"] = "text")

Source from the content-addressed store, hash-verified

170 self.send({"type": "websocket.receive", "bytes": data})
171
172 def send_json(self, data: Any, mode: Literal["text", "binary"] = "text") -> None:
173 text = json.dumps(data, separators=(",", ":"), ensure_ascii=False)
174 if mode == "text":
175 self.send({"type": "websocket.receive", "text": text})
176 else:
177 self.send({"type": "websocket.receive", "bytes": text.encode("utf-8")})
178
179 def close(self, code: int = 1000, reason: str | None = None) -> None:
180 self.send({"type": "websocket.disconnect", "code": code, "reason": reason})

Callers

nothing calls this directly

Calls 1

sendMethod · 0.95

Tested by

no test coverage detected