更新单元测试
This commit is contained in:
parent
0ca808c4fb
commit
c1775552cc
@ -12,6 +12,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/tidwall/sjson"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
@ -168,6 +170,12 @@ func TestExpandArrayPath(t *testing.T) {
|
||||
PathList: nil,
|
||||
PathMap: nil,
|
||||
}
|
||||
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", "", pathExpendRes)
|
||||
fmt.Println(pathExpendRes)
|
||||
ExpandArrayPath(jsonStr, "user_list.{{idx}}.{{idx}}.age", "a.{{idx}}.{{idx}}.b", 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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user