ReadJSON reads the next JSON-encoded message from the connection and stores it in the value pointed to by v. See the documentation for the encoding/json Unmarshal function for details about the conversion of JSON to a Go value.
(v interface{})
| 47 | // See the documentation for the encoding/json Unmarshal function for details |
| 48 | // about the conversion of JSON to a Go value. |
| 49 | func (c *Conn) ReadJSON(v interface{}) error { |
| 50 | _, r, err := c.NextReader() |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | err = json.NewDecoder(r).Decode(v) |
| 55 | if err == io.EOF { |
| 56 | // One value is expected in the message. |
| 57 | err = io.ErrUnexpectedEOF |
| 58 | } |
| 59 | return err |
| 60 | } |