修复拼写错误

This commit is contained in:
白茶清欢 2021-04-13 22:14:32 +08:00
parent 2fd996aa4c
commit d98822a5ee
2 changed files with 5 additions and 4 deletions

View File

@ -63,8 +63,9 @@ func TestSelect(t *testing.T) {
"slice": []int{1, 2, 3},
},
"slice": []int{1, 2, 3},
"map": map[string]interface{}{"a": 1, "b": 2, "c": 4},
}
pathList := []string{"name", "extra.age", "slice"}
pathList := []string{"name", "extra.age", "slice", "map"}
r, e := NewParseJSONTree(source).Parse(pathList)
fmt.Println(r.String(), e)
}

View File

@ -55,13 +55,13 @@ func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error) {
pathArr := strings.Split(path, "[]")
for idx, item := range pathArr {
val := gjson.Get(source, item)
isComplextType := val.IsArray()
isComplexType := val.IsArray()
if len(pathArr)-1 == idx {
// 当前是最后一项,说明不是数组
if isComplextType {
if isComplexType {
fmt.Println("这是一个数组")
}
result.SetValue(item, val.Raw, isComplextType)
result.SetValue(item, val.Raw, isComplexType)
continue
}
}