bytedance/sonic

unmarshal UTF8 escaped char with string option is different with encoding/json

已关闭

#279 创建于 2022年8月11日

 (0 条评论) (0 个反应) (1 位负责人)Go (454 个派生)github user discovery
buggood first issueknown-issue

仓库指标

星标
 (9,488 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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)

贡献者指南