We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
,string
func TestIssueStringTagMismatchSkip_decode(t *testing.T) { // match eo := []byte(`{"D":"20","E":1}`) et := reflect.TypeOf(IssueStringTag{}) testUnmarshal(t, eo, et, true) // mismatch eo = []byte(`{"D":11,"E":1}`) testUnmarshal(t, eo, et, true) // null eo = []byte(`{"D":null,"E":1}`) testUnmarshal(t, eo, et, true) } func testUnmarshal(t *testing.T, eo []byte, rt reflect.Type, checkobj bool) { obj := reflect.New(rt).Interface() println(string(eo)) println("sonic") es := sonic.Unmarshal(eo, obj) obj2 := reflect.New(rt).Interface() println("std") ee := json.Unmarshal(eo, obj2) assert.Equal(t, ee ==nil, es == nil, es) if checkobj { assert.Equal(t, obj2, obj) } fmt.Printf("std: %v, obj: %#v", ee, obj2) fmt.Printf("sonic error: %v, obj: %#v", es, obj) } type IssueStringTag struct { D int `form:"D" json:"D,string" query:"D"` E int }
Error: Not equal: expected: &issue_test.IssueStringTag{D:0, E:1} actual : &issue_test.IssueStringTag{D:0, E:0} Diff: --- Expected +++ Actual @@ -2,3 +2,3 @@ D: (int) 0, - E: (int) 1 + E: (int) 0 }) Test: TestIssueStringTagMismatchSkip_decode
The text was updated successfully, but these errors were encountered:
When ,string json tag defined, the json value should be {"D":"20","E":"1"}. If so, unmarshal works as expected.
{"D":"20","E":"1"}
Sorry, something went wrong.
No branches or pull requests
Reproducible codes
The text was updated successfully, but these errors were encountered: