From 38ebb8de55d531c72bd3ae9ff1de93014b34b249 Mon Sep 17 00:00:00 2001 From: Victor Starodub Date: Wed, 30 Mar 2016 16:05:50 +0300 Subject: [PATCH] Changed order of Unmarshal helper arguments to match encoding/json. --- helpers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helpers.go b/helpers.go index d85542d..b86b87d 100644 --- a/helpers.go +++ b/helpers.go @@ -5,9 +5,10 @@ import ( "io" "io/ioutil" "net/http" + "strconv" + "github.com/mailru/easyjson/jlexer" "github.com/mailru/easyjson/jwriter" - "strconv" ) // Marshaler is an easyjson-compatible marshaler interface. @@ -59,14 +60,14 @@ func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bo } // Unmarshal decodes the JSON in data into the object. -func Unmarshal(v Unmarshaler, data []byte) error { +func Unmarshal(data []byte, v Unmarshaler) error { l := jlexer.Lexer{Data: data} v.UnmarshalEasyJSON(&l) return l.Error() } // UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object. -func UnmarshalFromReader(v Unmarshaler, r io.Reader) error { +func UnmarshalFromReader(r io.Reader, v Unmarshaler) error { data, err := ioutil.ReadAll(r) if err != nil { return err