数组支持按项展开
This commit is contained in:
parent
33815072ea
commit
69066c35c2
@ -95,6 +95,7 @@ func doExpandPath(gjsonResult gjson.Result, rootPath string, hasChildren bool, p
|
||||
// 展开数组
|
||||
for idx, itemRes := range arrayList {
|
||||
doExpandPath(itemRes, rootPath+"."+fmt.Sprintf("%v", idx), true, pathOption, pathResult)
|
||||
doExpandPath(itemRes, rootPath+".{{idx}}", true, pathOption, pathResult)
|
||||
}
|
||||
} else {
|
||||
// 不展开数组
|
||||
@ -107,11 +108,12 @@ func doExpandPath(gjsonResult gjson.Result, rootPath string, hasChildren bool, p
|
||||
return
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(rootPath, ".#") {
|
||||
if strings.HasSuffix(rootPath, ".#") || strings.HasSuffix(rootPath, "{{idx}}") {
|
||||
// 处理不展开类型数组
|
||||
return
|
||||
}
|
||||
if pathOption.OnlyFinalPath && hasChildren {
|
||||
// 仅记录最终完整路径, 中间路径不记录
|
||||
return
|
||||
}
|
||||
if _, exist := pathResult.ValueTable[rootPath]; !exist {
|
||||
|
Loading…
Reference in New Issue
Block a user