sjson #1

Merged
zhangdeman merged 7 commits from sjson into master 2023-02-06 11:44:09 +08:00
2 changed files with 42 additions and 1 deletions
Showing only changes of commit 4a5f73bb02 - Show all commits

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