diff --git a/json_tool/filter.go b/json_tool/filter.go index 983cc70..0bdc292 100644 --- a/json_tool/filter.go +++ b/json_tool/filter.go @@ -70,7 +70,7 @@ func (f *Filter) Result() (*DynamicJSON, error) { data := item.Map() for _, key := range ketList { if v, exist := data[key]; exist { - result.SetValue(fmt.Sprintf(pathArr[0]+".[%d]."+key, idx), data[key].Raw, v.IsObject() || v.IsArray()) + result.SetValue(strings.ReplaceAll(newDataPath, "[]", fmt.Sprintf("[%d]", idx)), data[key].Raw, v.IsObject() || v.IsArray()) } // 结果集中不存在对应key,丢弃 }