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<白茶清欢>