diff --git a/array.go b/array.go index 0a932bd..27e49a7 100644 --- a/array.go +++ b/array.go @@ -56,3 +56,18 @@ func (at *ArrayType) IsValid() bool { } return strings.HasPrefix(string(byteData), "[") && strings.HasSuffix(string(byteData), "]") } + +// ItemIsInterface 数组每一项是否为interface +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 21:20 2023/6/11 +func (at *ArrayType) ItemIsInterface() bool { + if !at.IsValid() { + return false + } + if _, ok := at.value.([]interface{}); ok { + return true + } + return false +} diff --git a/array_test.go b/array_test.go index d62d9e0..baddf77 100644 --- a/array_test.go +++ b/array_test.go @@ -13,6 +13,7 @@ import ( ) func TestArray(t *testing.T) { - val := []int64{1, 2, 3} + val := []interface{}{1, 2, 3} fmt.Println(Array(val).IsValid()) + fmt.Println(Array(val).ItemIsInterface()) }