From c92a8516d4e354c647adf30442a8b1052d1b9fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 10 Sep 2021 11:45:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8D=95=E5=B1=82slice?= =?UTF-8?q?=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- json_tool/filter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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,丢弃 }