Skip to content

Commit

Permalink
Use WriteJSON and ReadJSON on Conn struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
tapocol authored and garyburd committed Oct 28, 2013
1 parent 1627eef commit 8e0dceb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,7 @@ import (
//
// See the documentation for encoding/json Marshal for details about the
// conversion of Go values to JSON.
func WriteJSON(c *Conn, v interface{}) error {
func (c *Conn) WriteJSON(v interface{}) error {
w, err := c.NextWriter(TextMessage)
if err != nil {
return err
Expand All @@ -30,7 30,7 @@ func WriteJSON(c *Conn, v interface{}) error {
//
// See the documentation for the encoding/json Marshal function for details
// about the conversion of JSON to a Go value.
func ReadJSON(c *Conn, v interface{}) error {
func (c *Conn) ReadJSON(v interface{}) error {
_, r, err := c.NextReader()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 23,11 @@ func TestJSON(t *testing.T) {
expect.A = 1
expect.B = "hello"

if err := WriteJSON(wc, &expect); err != nil {
if err := wc.WriteJSON(&expect); err != nil {
t.Fatal("write", err)
}

if err := ReadJSON(rc, &actual); err != nil {
if err := rc.ReadJSON(&actual); err != nil {
t.Fatal("read", err)
}

Expand Down

0 comments on commit 8e0dceb

Please sign in to comment.