bytedance/sonic

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

Geschlossen

#279 geöffnet am 11.08.2022

 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Go (454 Forks)github user discovery
buggood first issueknown-issue

Repository-Metriken

Stars
 (9.488 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 12T 6h) (3 gemergte PRs in 30 T)

Beschreibung

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)

Contributor Guide