Skip to content

Commit cecf9f2

Browse files
authored
feat: change sonic to encoding/json (cloudwego#108)
1 parent 43fe11a commit cecf9f2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/utils/serdes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@
1717
package utils
1818

1919
import (
20-
"github.com/bytedance/sonic"
20+
"encoding/json"
2121
)
2222

2323
func MarshalJSONIndent(input any) (string, error) {
24-
js, err := sonic.MarshalIndent(input, "", " ")
24+
js, err := json.MarshalIndent(input, "", " ")
2525
if err != nil {
2626
return "", err
2727
}
2828
return string(js), nil
2929
}
3030

3131
func MarshalJSONIndentNoError(input any) string {
32-
js, err := sonic.MarshalIndent(input, "", " ")
32+
js, err := json.MarshalIndent(input, "", " ")
3333
if err != nil {
3434
return ""
3535
}
3636
return string(js)
3737
}
3838

3939
func MarshalJSONBytes(input any) ([]byte, error) {
40-
return sonic.Marshal(input)
40+
return json.Marshal(input)
4141
}
4242

4343
func UnmarshalJSON(input string, output any) error {
44-
return sonic.UnmarshalString(input, output)
44+
return json.Unmarshal([]byte(input), output)
4545
}
4646

4747
func UnmarshalJSONBytes(input []byte, output any) error {
48-
return sonic.Unmarshal(input, output)
48+
return json.Unmarshal(input, output)
4949
}

0 commit comments

Comments
 (0)