增加兼容的GetMany方法

This commit is contained in:
白茶清欢 2024-12-05 16:34:29 +08:00
parent f88826411f
commit f61f9b28b1

View File

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