修复拼写错误
This commit is contained in:
parent
2fd996aa4c
commit
d98822a5ee
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user