更新单元测试
This commit is contained in:
@ -12,6 +12,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/tidwall/sjson"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -168,6 +170,12 @@ func TestExpandArrayPath(t *testing.T) {
|
|||||||
PathList: nil,
|
PathList: nil,
|
||||||
PathMap: nil,
|
PathMap: nil,
|
||||||
}
|
}
|
||||||
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", "", pathExpendRes)
|
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", "a.{{idx}}.{{idx}}.b", pathExpendRes)
|
||||||
fmt.Println(pathExpendRes)
|
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.name", "a.{{idx}}.{{idx}}.c", pathExpendRes)
|
||||||
|
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.sex", "a.{{idx}}.{{idx}}.c", pathExpendRes)
|
||||||
|
res := ""
|
||||||
|
for _, item := range pathExpendRes.PathList {
|
||||||
|
res, _ = sjson.Set(res, pathExpendRes.PathMap[item], gjson.Get(jsonStr, item).Value())
|
||||||
|
}
|
||||||
|
fmt.Println(res)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user