bytedance/sonic

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

Chiusa

#279 aperta il 11 ago 2022

 (0 commenti) (0 reazioni) (1 assegnatario)Go (454 fork)github user discovery
buggood first issueknown-issue

Metriche repository

Star
 (9488 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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)

Guida contributor