From 8e0dcebbf09789d5e00a6e40621d47cee5eeab56 Mon Sep 17 00:00:00 2001 From: Craig Jackson Date: Sat, 26 Oct 2013 01:13:32 -0700 Subject: [PATCH] Use WriteJSON and ReadJSON on Conn struct. --- json.go | 4 ++-- json_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/json.go b/json.go index 4b340d7..880c13b 100644 --- a/json.go +++ b/json.go @@ -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 @@ -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 diff --git a/json_test.go b/json_test.go index a373844..365c42a 100644 --- a/json_test.go +++ b/json_test.go @@ -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) }