You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func TestJson(t *testing.T) {
type info struct {
Id int64 `json:"id"`
}
type test struct {
Result []info `json:"result"`
}
r := `{"result":[{"id":"1"},{"id":"2"}]}`
var res1 test
var res2 test
// use encoding/json
json2.Unmarshal([]byte(r), &res1)
// use json-iterator/go
jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal([]byte(r), &res2)
len1 := len(res1.Result) // 2
len2 := len(res2.Result) // 1
fmt.Println(len1, len2)
}
I want to know which handling behavior is more appropriate.
The text was updated successfully, but these errors were encountered:
I want to know which handling behavior is more appropriate.
The text was updated successfully, but these errors were encountered: