2025-03-29 15:47:56 +08:00

51 lines
1.2 KiB
Go

// 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 // 路径对应的值
}
const (
ArrayIdxTpl = "[]"
)
// ExpendArrayResult 展开数组的结果
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:46 2024/11/29
type ExpendArrayResult struct {
PathList []string `json:"path_list"` // 路径列表
PathMap map[string]string `json:"path_map"` // 数据源路径 => 目标路径的处理
}
const (
SpecialKeyStart = "{{#"
SpecialKeyEnd = "#}}"
)