Skip to content

Commit b85543a

Browse files
committed
Use jsoniter for improved performance
1 parent 77b7bd3 commit b85543a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

client/Client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package client
22

33
import (
4-
"encoding/json"
54
"log"
65
"strings"
76

7+
jsoniter "github.com/json-iterator/go"
88
"github.com/valyala/fasthttp"
99
)
1010

@@ -66,7 +66,7 @@ func (http *Client) Body(raw string) *Client {
6666

6767
// BodyJSON sets the request body by converting the object to JSON.
6868
func (http *Client) BodyJSON(obj interface{}) *Client {
69-
data, err := json.Marshal(obj)
69+
data, err := jsoniter.Marshal(obj)
7070

7171
if err != nil {
7272
log.Printf("Error converting request body to JSON: %v", err)

client/Response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package client
22

33
import (
44
"bytes"
5-
"encoding/json"
65

6+
jsoniter "github.com/json-iterator/go"
77
"github.com/valyala/fasthttp"
88
)
99

@@ -53,5 +53,5 @@ func (response Response) RawBytes() []byte {
5353

5454
// Unmarshal tries to JSON decode the response and save it in the object.
5555
func (response Response) Unmarshal(obj interface{}) error {
56-
return json.Unmarshal(response.Bytes(), obj)
56+
return jsoniter.Unmarshal(response.Bytes(), obj)
5757
}

0 commit comments

Comments
 (0)