Skip to content

Commit

Permalink
Update goccy/go-json to 0.8.1 (#1644)
Browse files Browse the repository at this point in the history
* Update goccy/go-json to 0.8.1

* Fix linter.

* Update error.go
  • Loading branch information
efectn committed Dec 6, 2021
1 parent 5e37126 commit 10aa7f7
Show file tree
Hide file tree
Showing 20 changed files with 3,310 additions and 4,084 deletions.
33 changes: 33 additions & 0 deletions client_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/tls"
"encoding/base64"
stdjson "encoding/json"
"errors"
"io"
"io/ioutil"
Expand Down Expand Up @@ -560,6 +561,38 @@ func Test_Client_Agent_Dest(t *testing.T) {
})
}

func Test_Client_Stdjson_Gojson(t *testing.T) {
type User struct {
Account *string `json:"account"`
Password *string `json:"password"`
Nickname *string `json:"nickname"`
Address *string `json:"address,omitempty"`
Friends []*User `json:"friends,omitempty"`
}
user1Account, user1Password, user1Nickname := "abcdef", "123456", "user1"
user1 := &User{
Account: &user1Account,
Password: &user1Password,
Nickname: &user1Nickname,
Address: nil,
}
user2Account, user2Password, user2Nickname := "ghijkl", "123456", "user2"
user2 := &User{
Account: &user2Account,
Password: &user2Password,
Nickname: &user2Nickname,
Address: nil,
}
user1.Friends = []*User{user2}
expected, err := stdjson.Marshal(user1)
utils.AssertEqual(t, nil, err)

got, err := json.Marshal(user1)
utils.AssertEqual(t, nil, err)

utils.AssertEqual(t, expected, got)
}

func Test_Client_Agent_Json(t *testing.T) {
handler := func(c *Ctx) error {
utils.AssertEqual(t, MIMEApplicationJSON, string(c.Request().Header.ContentType()))
Expand Down
3 changes: 1 addition & 2 deletions internal/go-json/cmd/generator/main.go
Expand Up @@ -120,7 +120,7 @@ func (t OpType) HeadToOmitEmptyHead() OpType {
}
func (t OpType) PtrHeadToHead() OpType {
idx := strings.Index(t.String(), "Ptr")
idx := strings.Index(t.String(), "PtrHead")
if idx == -1 {
return t
}
Expand Down Expand Up @@ -201,7 +201,6 @@ func (t OpType) FieldToOmitEmptyField() OpType {
createOpType("RecursivePtr", "Op"),
createOpType("RecursiveEnd", "Op"),
createOpType("InterfaceEnd", "Op"),
createOpType("StructAnonymousEnd", "StructEnd"),
}
for _, typ := range primitiveTypesUpper {
typ := typ
Expand Down

0 comments on commit 10aa7f7

Please sign in to comment.