基于gjson,递归获取全部key的路径

This commit is contained in:
2024-11-27 16:07:32 +08:00
parent d115e1c5ba
commit 435edb0ea3
3 changed files with 247 additions and 0 deletions

31
gjson_hack/define.go Normal file
View File

@ -0,0 +1,31 @@
// Package gjson_hack ...
//
// Description : gjson_hack ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-11-27 11:59
package gjson_hack
import "github.com/tidwall/gjson"
// PathOption 路径操作的选项
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 12:01 2024/11/27
type PathOption struct {
UnfoldArray bool `json:"unfold_array"` // 展开数组
MaxDeep int `json:"max_deep"` // 迭代最大深度, 默认 0 不限制
OnlyFinalPath bool `json:"only_final_path"` // 仅展示最终路径
}
// PathResult ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 12:00 2024/11/27
type PathResult struct {
List []string // 全部路径列表
ValueTable map[string]gjson.Result // 路径对应的值
}