Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liuq19 opened this issue Aug 11, 2022 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers known-issue This issue is known to us, we are working on it

Comments

@liuq19
Copy link
Collaborator

liuq19 commented Aug 11, 2022

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)
@AsterDY AsterDY changed the title unmarshal struct with string option is different with encoding/json unmarshal UTF8 escaped char with string option is different with encoding/json Aug 15, 2022
@AsterDY AsterDY added the known-issue This issue is known to us, we are working on it label Aug 22, 2022
@liuq19 liuq19 added good first issue Good for newcomers bug Something isn't working labels May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers known-issue This issue is known to us, we are working on it
Projects
None yet
Development

No branches or pull requests

2 participants