diff --git a/account.go b/account.go index c78cac7..0040ca4 100644 --- a/account.go +++ b/account.go @@ -1,10 +1,10 @@ package telegraph import ( - "encoding/json" "fmt" "strings" + json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) diff --git a/page.go b/page.go index c6e89d7..1576c78 100644 --- a/page.go +++ b/page.go @@ -1,10 +1,10 @@ package telegraph import ( - "encoding/json" "fmt" "strconv" + json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) diff --git a/telegraph.go b/telegraph.go index 9f21f68..9c3e1cc 100644 --- a/telegraph.go +++ b/telegraph.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" + ffjson "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) @@ -133,19 +134,19 @@ type ( ) func request(url string, args *http.Args) (*Response, error) { - _, resp, err := http.Post(nil, url, args) + _, body, err := http.Post(nil, url, args) if err != nil { return nil, err } - var tResp Response - if err := json.Unmarshal(resp, &tResp); err != nil { + var resp Response + if err := ffjson.Unmarshal(body, &resp); err != nil { return nil, err } - if !tResp.Ok { - return nil, errors.New(tResp.Error) + if !resp.Ok { + return nil, errors.New(resp.Error) } - return &tResp, nil + return &resp, nil }