This commit is contained in:
白茶清欢 2023-01-07 23:24:55 +08:00
parent 3dff92188f
commit 4a5f73bb02
2 changed files with 42 additions and 1 deletions

View File

@ -14,8 +14,9 @@ import (
"github.com/tidwall/sjson"
"errors"
"git.zhangdeman.cn/zhangdeman/util"
"github.com/pkg/errors"
"github.com/tidwall/gjson"
)

View File

@ -118,3 +118,43 @@ func TestNewFilterForArrayOne(t *testing.T) {
fmt.Println(f.String())
})
}
// TestNewFilterForArrayTwo ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 22:22 2023/1/2
func TestNewFilterForArrayTwo(t *testing.T) {
var (
err error
)
testData := `{"user_list":[
{
"name":"zhangdeman1"
},
{
"name":"zhang1"
},
{
"name":"de1"
},
{
"name":"man1"
}
]}`
filterRuleList := []MapRule{
{
SourcePath: "user_list.[].name",
MapPath: "user.name_list.[]",
Required: true,
DataType: "string",
DefaultValue: "",
},
}
f := NewFilter(testData, filterRuleList)
convey.Convey("提取列表字段,构成新的列表", t, func() {
err = f.Deal()
convey.So(err, convey.ShouldEqual, nil)
fmt.Println(f.String())
})
}