From f61f9b28b113ade5b2f2abd30dcc148ef4a9b13e 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, 5 Dec 2024 16:34:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=BC=E5=AE=B9=E7=9A=84Ge?= =?UTF-8?q?tMany=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gjson_hack/path.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gjson_hack/path.go b/gjson_hack/path.go index 496585f..85e3f7b 100644 --- a/gjson_hack/path.go +++ b/gjson_hack/path.go @@ -321,6 +321,20 @@ func Get(gjsonResult gjson.Result, path string) gjson.Result { return gjsonResult } +// GetMany 兼容 gjson GetMany 方法 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:32 2024/12/5 +func GetMany(jsonStr string, pathList ...string) []gjson.Result { + res := make([]gjson.Result, 0) + gjsonResult := gjson.Parse(jsonStr) + for _, itemPath := range pathList { + res = append(res, Get(gjsonResult, itemPath)) + } + return res +} + // IsSpecialPath 判断传入的是否为特殊路径 // // Author : go_developer@163.com<白茶清欢>