测试用例增加二维数组, 理论上支持无线多维!!!

This commit is contained in:
白茶清欢 2025-03-22 23:32:09 +08:00
parent 45b13811c4
commit 5289d9278c

View File

@ -27,6 +27,7 @@ func Test_dynamicStructImpl_New(t *testing.T) {
AddField("user.job.address", "", "", `json:"address"`, false).
AddField("user.job.company.name", "", "", `json:"name"`, false).
AddField("arr.[].item.name", "", "", `json:"name"`, false).
AddField("arr2.[].[].item.name", "", "", `json:"name"`, false).
Build()
val := instance.New()
@ -39,7 +40,8 @@ func Test_dynamicStructImpl_New(t *testing.T) {
"Slice": [1, 2, 3],
"user": {"job":{"address":"beijing","company":{"name":"unknown"}}, "base":{"age": 1800, "name":"baicha"}},
"Anonymous": "avoid to read",
"arr": [{"item":{"name":"item1","test":1}},{"item":{"name":"item2", "test":2}}]
"arr": [{"item":{"name":"item1","test":1}},{"item":{"name":"item2", "test":2}}],
"arr2": [[{"item":{"name":"item1","test":1}},{"item":{"name":"item2", "test":2}}]]
}
`)
tType := reflect.TypeOf(val)