Skip to content

Commit

Permalink
up:
Browse files Browse the repository at this point in the history
  • Loading branch information
wln32 committed Apr 9, 2024
1 parent c90316d commit 63c020f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 2 additions & 8 deletions util/gconv/gconv_slice_str.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func Strings(any interface{}) []string {
}
case []uint8:
if json.Valid(value) {
// Determine whether it is JSON in array format
if value[0] == '[' && value[len(value)-1] == ']' {
_ = json.UnmarshalUseNumber(value, &array)
}
_ = json.UnmarshalUseNumber(value, &array)
}
// Prevent strings from being null
// See Issue 3465 for details
Expand All @@ -83,10 +80,7 @@ func Strings(any interface{}) []string {
case string:
byteValue := []byte(value)
if json.Valid(byteValue) {
// Determine whether it is JSON in array format
if byteValue[0] == '[' && byteValue[len(value)-1] == ']' {
_ = json.UnmarshalUseNumber(byteValue, &array)
}
_ = json.UnmarshalUseNumber(byteValue, &array)
}
// Prevent strings from being null
// See Issue 3465 for details
Expand Down
1 change: 1 addition & 0 deletions util/gconv/gconv_z_unit_slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ func Test_Strings(t *testing.T) {
t.AssertEQ(gconv.Strings(array), []string{"1", "2", "3"})

t.AssertEQ(gconv.Strings([]uint8(`["1","2"]`)), []string{"1", "2"})
t.AssertEQ(gconv.Strings([]uint8(` ["1","2"] `)), []string{"1", "2"})
t.AssertEQ(gconv.Strings([][]byte{{byte(0)}, {byte(1)}}), []string{"\u0000", "\u0001"})
})
// https://github.com/gogf/gf/issues/1750
Expand Down

0 comments on commit 63c020f

Please sign in to comment.