MCPcopy
hub / github.com/encode/starlette / send_json

Method send_json

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

Source from the content-addressed store, hash-verified

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