...
1
16
17 package issue_test
18
19 import (
20 `encoding/json`
21 `testing`
22
23 `github.com/bytedance/sonic`
24 `github.com/stretchr/testify/require`
25 )
26
27 type Issue403 struct {
28 Card PtrAlias `json:"card"`
29 }
30
31 type PtrAlias *MarshalerImpl
32
33 type MarshalerImpl struct{
34 A int
35 }
36
37 func (self *MarshalerImpl) MarshalJSON() ([]byte, error) {
38 return []byte("1"), nil
39 }
40
41 func TestIssue403(t *testing.T) {
42 obj := MarshalerImpl{0}
43 messageInfo := &Issue403{
44 Card: &obj,
45 }
46
47 jsonData, err := json.Marshal(messageInfo)
48 require.NoError(t, err)
49 sonicData, err := sonic.Marshal(messageInfo)
50 require.NoError(t, err)
51 require.Equal(t, jsonData, sonicData)
52 }
View as plain text