mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix issue #1750
This commit is contained in:
@ -264,14 +264,18 @@ func checkJsonAndUnmarshalUseNumber(any interface{}, target interface{}) bool {
|
||||
switch r := any.(type) {
|
||||
case []byte:
|
||||
if json.Valid(r) {
|
||||
_ = json.UnmarshalUseNumber(r, &target)
|
||||
if err := json.UnmarshalUseNumber(r, &target); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
case string:
|
||||
anyAsBytes := []byte(r)
|
||||
if json.Valid(anyAsBytes) {
|
||||
_ = json.UnmarshalUseNumber(anyAsBytes, &target)
|
||||
if err := json.UnmarshalUseNumber(anyAsBytes, &target); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +103,10 @@ func Test_Strings(t *testing.T) {
|
||||
}
|
||||
t.AssertEQ(gconv.Strings(array), []string{"1", "2", "3"})
|
||||
})
|
||||
// https://github.com/gogf/gf/issues/1750
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
t.AssertEQ(gconv.Strings("123"), []string{"123"})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Slice_Interfaces(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user