fix ci issue

This commit is contained in:
John Guo 2021-09-15 21:46:58 +08:00
parent e877eab033
commit ac78b2fa50
2 changed files with 7 additions and 1 deletions

View File

@ -709,7 +709,7 @@ func TestArray_UnmarshalValue(t *testing.T) {
"name": "john",
"array": []byte(`[1,2,3]`),
}, &v)
t.Assert(err, nil)
t.AssertNil(err)
t.Assert(v.Name, "john")
t.Assert(v.Array.Slice(), g.Slice{1, 2, 3})
})

View File

@ -59,6 +59,9 @@ func doStructWithJsonCheck(params interface{}, pointer interface{}) (err error,
if json.Valid(r) {
if rv, ok := pointer.(reflect.Value); ok {
if rv.Kind() == reflect.Ptr {
if rv.IsNil() {
return nil, false
}
return json.UnmarshalUseNumber(r, rv.Interface()), true
} else if rv.CanAddr() {
return json.UnmarshalUseNumber(r, rv.Addr().Interface()), true
@ -71,6 +74,9 @@ func doStructWithJsonCheck(params interface{}, pointer interface{}) (err error,
if paramsBytes := []byte(r); json.Valid(paramsBytes) {
if rv, ok := pointer.(reflect.Value); ok {
if rv.Kind() == reflect.Ptr {
if rv.IsNil() {
return nil, false
}
return json.UnmarshalUseNumber(paramsBytes, rv.Interface()), true
} else if rv.CanAddr() {
return json.UnmarshalUseNumber(paramsBytes, rv.Addr().Interface()), true