feature/upgrade_filter #7

Merged
zhangdeman merged 14 commits from feature/upgrade_filter into master 2024-12-02 14:35:30 +08:00
Showing only changes of commit c1775552cc - Show all commits

View File

@ -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)
}