修复list提取错误问题
This commit is contained in:
parent
10efd5d757
commit
dfc58c7052
@ -75,12 +75,12 @@ func (f *Filter) Result() (*DynamicJSON, error) {
|
|||||||
}
|
}
|
||||||
// 支持list再抽取一层,处于性能考虑,这么限制,不做递归无限深度处理
|
// 支持list再抽取一层,处于性能考虑,这么限制,不做递归无限深度处理
|
||||||
// 还能继续抽取,就认为是 []map[string]interface{}
|
// 还能继续抽取,就认为是 []map[string]interface{}
|
||||||
ketList := strings.Split(pathArr[1], ".")
|
keyList := strings.Split(pathArr[1], ".")
|
||||||
for idx, item := range val.Array() {
|
for idx, item := range val.Array() {
|
||||||
data := item.Map()
|
data := item.Map()
|
||||||
for _, key := range ketList {
|
for _, key := range keyList {
|
||||||
if v, exist := data[key]; exist {
|
if _, exist := data[key]; exist {
|
||||||
result.SetValue(strings.ReplaceAll(newDataRule.MapKey, "[]", fmt.Sprintf("[%d]", idx)), data[key].Value(), v.IsObject() || v.IsArray())
|
result.SetValue(strings.ReplaceAll(newDataRule.MapKey, "[]", fmt.Sprintf("[%d]", idx)), data[key].String(), newDataRule.IsComplexType)
|
||||||
} else {
|
} else {
|
||||||
// 结果集中不存在对应key,设置默认值
|
// 结果集中不存在对应key,设置默认值
|
||||||
result.SetValue(strings.ReplaceAll(newDataRule.MapKey, "[]", fmt.Sprintf("[%d]", idx)), newDataRule.DefaultValue, newDataRule.IsComplexType)
|
result.SetValue(strings.ReplaceAll(newDataRule.MapKey, "[]", fmt.Sprintf("[%d]", idx)), newDataRule.DefaultValue, newDataRule.IsComplexType)
|
||||||
|
Loading…
Reference in New Issue
Block a user