Skip to content

Commit 10aa7f7

Browse files
authored
Update goccy/go-json to 0.8.1 (#1644)
* Update goccy/go-json to 0.8.1 * Fix linter. * Update error.go
1 parent 5e37126 commit 10aa7f7

File tree

20 files changed

+3310
-4084
lines changed

20 files changed

+3310
-4084
lines changed

client_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"crypto/tls"
66
"encoding/base64"
7+
stdjson "encoding/json"
78
"errors"
89
"io"
910
"io/ioutil"
@@ -560,6 +561,38 @@ func Test_Client_Agent_Dest(t *testing.T) {
560561
})
561562
}
562563

564+
func Test_Client_Stdjson_Gojson(t *testing.T) {
565+
type User struct {
566+
Account *string `json:"account"`
567+
Password *string `json:"password"`
568+
Nickname *string `json:"nickname"`
569+
Address *string `json:"address,omitempty"`
570+
Friends []*User `json:"friends,omitempty"`
571+
}
572+
user1Account, user1Password, user1Nickname := "abcdef", "123456", "user1"
573+
user1 := &User{
574+
Account: &user1Account,
575+
Password: &user1Password,
576+
Nickname: &user1Nickname,
577+
Address: nil,
578+
}
579+
user2Account, user2Password, user2Nickname := "ghijkl", "123456", "user2"
580+
user2 := &User{
581+
Account: &user2Account,
582+
Password: &user2Password,
583+
Nickname: &user2Nickname,
584+
Address: nil,
585+
}
586+
user1.Friends = []*User{user2}
587+
expected, err := stdjson.Marshal(user1)
588+
utils.AssertEqual(t, nil, err)
589+
590+
got, err := json.Marshal(user1)
591+
utils.AssertEqual(t, nil, err)
592+
593+
utils.AssertEqual(t, expected, got)
594+
}
595+
563596
func Test_Client_Agent_Json(t *testing.T) {
564597
handler := func(c *Ctx) error {
565598
utils.AssertEqual(t, MIMEApplicationJSON, string(c.Request().Header.ContentType()))

internal/go-json/cmd/generator/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (t OpType) HeadToOmitEmptyHead() OpType {
120120
}
121121
122122
func (t OpType) PtrHeadToHead() OpType {
123-
idx := strings.Index(t.String(), "Ptr")
123+
idx := strings.Index(t.String(), "PtrHead")
124124
if idx == -1 {
125125
return t
126126
}
@@ -201,7 +201,6 @@ func (t OpType) FieldToOmitEmptyField() OpType {
201201
createOpType("RecursivePtr", "Op"),
202202
createOpType("RecursiveEnd", "Op"),
203203
createOpType("InterfaceEnd", "Op"),
204-
createOpType("StructAnonymousEnd", "StructEnd"),
205204
}
206205
for _, typ := range primitiveTypesUpper {
207206
typ := typ

0 commit comments

Comments
 (0)