1
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
12
// WriteJSON is deprecated, use c.WriteJSON instead.
13
func WriteJSON(c *Conn, v interface{}) error {
17
// WriteJSON writes the JSON encoding of v to the connection.
19
// See the documentation for encoding/json Marshal for details about the
20
// conversion of Go values to JSON.
21
func (c *Conn) WriteJSON(v interface{}) error {
22
w, err := c.NextWriter(TextMessage)
26
err1 := json.NewEncoder(w).Encode(v)
34
// ReadJSON is deprecated, use c.ReadJSON instead.
35
func ReadJSON(c *Conn, v interface{}) error {
39
// ReadJSON reads the next JSON-encoded message from the connection and stores
40
// it in the value pointed to by v.
42
// See the documentation for the encoding/json Unmarshal function for details
43
// about the conversion of JSON to a Go value.
44
func (c *Conn) ReadJSON(v interface{}) error {
45
_, r, err := c.NextReader()
49
err = json.NewDecoder(r).Decode(v)
51
// One value is expected in the message.
52
err = io.ErrUnexpectedEOF