From 617c1edc350c2d09c9c5140fd89469630966fcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E6=BB=A1?= Date: Fri, 12 Mar 2021 13:40:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json/build.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/build.go b/json/build.go index c888656..e9eab18 100644 --- a/json/build.go +++ b/json/build.go @@ -22,7 +22,7 @@ const ( // JSONode JSOM节点 // -// Author : zhangdeman001@ke.com<张德满> +// Author : go_developer@163.com<张德满> // // Date : 10:33 下午 2021/3/10 type JSONode struct { From c2bcab795d09b02ed9b5be7efc4d4e243a9b5d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BE=B7=E6=BB=A1?= Date: Fri, 12 Mar 2021 13:53:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json/build.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/json/build.go b/json/build.go index 65c4ae3..2c4c709 100644 --- a/json/build.go +++ b/json/build.go @@ -217,11 +217,12 @@ func (dj *DynamicJSON) extraSliceIndex(key string) (bool, int) { // slice 至少是 [1] 格式 return false, 0 } - // 不用正则,直接字符串处理 - strByte := []byte(key) - if string(strByte[0:1]) != "[" || string(strByte[len(strByte)-1:]) != "]" { + + if !strings.HasPrefix(key, "[") || !strings.HasSuffix(key, "]") { return false, 0 } + // 不用正则,直接字符串处理 + strByte := []byte(key) index, err := strconv.Atoi(string(strByte[1 : len(strByte)-1])) if nil != err { return false, 0