From fbecc18e2e4d4eb863a990a57218305f190ae6db Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 9 Jun 2018 17:32:58 +0800 Subject: *: use jsoniter to replace encoding/json --- pkg/httplib/httplib.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pkg/httplib') diff --git a/pkg/httplib/httplib.go b/pkg/httplib/httplib.go index deca5db5..55b17d93 100644 --- a/pkg/httplib/httplib.go +++ b/pkg/httplib/httplib.go @@ -8,7 +8,6 @@ package httplib import ( "bytes" "crypto/tls" - "encoding/json" "encoding/xml" "io" "io/ioutil" @@ -23,6 +22,8 @@ import ( "strings" "sync" "time" + + "github.com/json-iterator/go" ) var defaultSetting = Settings{false, "GogsServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false} @@ -416,8 +417,7 @@ func (r *Request) ToJson(v interface{}) error { if err != nil { return err } - err = json.Unmarshal(data, v) - return err + return jsoniter.Unmarshal(data, v) } // ToXml returns the map that marshals from the body bytes as xml in response . @@ -427,8 +427,7 @@ func (r *Request) ToXml(v interface{}) error { if err != nil { return err } - err = xml.Unmarshal(data, v) - return err + return xml.Unmarshal(data, v) } // Response executes request client gets response mannually. -- cgit v1.2.3