sonic
sonic copied to clipboard
unmarshal UTF8 escaped char with string option is different with encoding/json
code:
package issue_test
import (
`testing`
. `github.com/bytedance/sonic`
`encoding/json`
`github.com/stretchr/testify/require`
)
type StringOptQuote struct {
F0 string "json:\"S,string\""
}
func TestUnmarshal_StringOption(t *testing.T) {
var jv, sv StringOptQuote
data := []byte(`{"S":"\"\u0026\""}`)
je := json.Unmarshal(data, &jv)
se := Unmarshal(data, &sv)
require.Equal(t, je != nil, se != nil)
require.Equal(t, jv, sv)
}
output:
=== RUN TestUnmarshal_StringOption
issuex3_test.go:37:
Error Trace: issuex3_test.go:37
Error: Not equal:
expected: false
actual : true
Test: TestUnmarshal_StringOption
--- FAIL: TestUnmarshal_StringOption (0.01s)