MCPcopy
hub / github.com/gorilla/websocket / WriteJSON

Method WriteJSON

json.go:23–34  ·  json.go::Conn.WriteJSON

WriteJSON writes the JSON encoding of v as a message. See the documentation for encoding/json Marshal for details about the conversion of Go values to JSON.

(v interface{})

Source from the content-addressed store, hash-verified

21// See the documentation for encoding/json Marshal for details about the
22// conversion of Go values to JSON.
23func (c *Conn) WriteJSON(v interface{}) error {
24 w, err := c.NextWriter(TextMessage)
25 if err != nil {
26 return err
27 }
28 err1 := json.NewEncoder(w).Encode(v)
29 err2 := w.Close()
30 if err1 != nil {
31 return err1
32 }
33 return err2
34}
35
36// ReadJSON reads the next JSON-encoded message from the connection and stores
37// it in the value pointed to by v.

Callers 2

TestJSONFunction · 0.80
WriteJSONFunction · 0.80

Calls 2

NextWriterMethod · 0.95
CloseMethod · 0.45

Tested by 1

TestJSONFunction · 0.64