增加转为字符串
This commit is contained in:
parent
faafa8ee2a
commit
9f0b7008a4
29
array.go
29
array.go
@ -201,6 +201,22 @@ func (at *Array) Convert() ([]interface{}, error) {
|
||||
at.itemType = reflect.Interface
|
||||
at.convertResult = make([]interface{}, len(val))
|
||||
copy(at.convertResult, val)
|
||||
case []struct{}:
|
||||
at.isSimpleSlice = false
|
||||
at.itemType = reflect.Interface
|
||||
at.convertResult = make([]interface{}, len(val))
|
||||
for i := 0; i < len(val); i++ {
|
||||
at.convertResult[i] = val[i]
|
||||
}
|
||||
case []map[string]interface{}:
|
||||
at.isSimpleSlice = false
|
||||
at.itemType = reflect.Interface
|
||||
at.convertResult = make([]interface{}, len(val))
|
||||
for i := 0; i < len(val); i++ {
|
||||
at.convertResult[i] = val[i]
|
||||
}
|
||||
default:
|
||||
|
||||
}
|
||||
return at.convertResult, nil
|
||||
}
|
||||
@ -267,3 +283,16 @@ func (at *Array) Has(input interface{}) int {
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// ToString ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:57 2023/9/28
|
||||
func (at *Array) ToString() string {
|
||||
if at.IsNil() {
|
||||
return ""
|
||||
}
|
||||
byteData, _ := json.Marshal(at.convertResult)
|
||||
return string(byteData)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user