From 9f0b7008a461f1ec447de74b99625c5ba4298fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 28 Sep 2023 17:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=AC=E4=B8=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- array.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/array.go b/array.go index 1d21b88..0d5f8a8 100644 --- a/array.go +++ b/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) +}