mark gconv.StructDeep/StructsDeep deprecated

This commit is contained in:
John
2020-11-05 23:02:29 +08:00
parent 176dcdc7cc
commit 9f04e46166
15 changed files with 74 additions and 186 deletions

View File

@ -315,6 +315,7 @@ func (j *Json) GetStruct(pattern string, pointer interface{}, mapping ...map[str
}
// GetStructDeep does GetStruct recursively.
// Deprecated, use GetStruct instead.
func (j *Json) GetStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error {
return gconv.StructDeep(j.Get(pattern), pointer, mapping...)
}
@ -325,6 +326,7 @@ func (j *Json) GetStructs(pattern string, pointer interface{}, mapping ...map[st
}
// GetStructsDeep converts any slice to given struct slice recursively.
// Deprecated, use GetStructs instead.
func (j *Json) GetStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error {
return gconv.StructsDeep(j.Get(pattern), pointer, mapping...)
}
@ -394,6 +396,7 @@ func (j *Json) ToStruct(pointer interface{}, mapping ...map[string]string) error
// ToStructDeep converts current Json object to specified object recursively.
// The <pointer> should be a pointer type of *struct.
// Deprecated, use ToStruct instead.
func (j *Json) ToStructDeep(pointer interface{}, mapping ...map[string]string) error {
j.mu.RLock()
defer j.mu.RUnlock()

View File

@ -203,7 +203,7 @@ func Test_ToStruct1(t *testing.T) {
})
}
func Test_ToStructDeep(t *testing.T) {
func Test_ToStruct(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
type Item struct {
Title string `json:"title"`
@ -231,7 +231,7 @@ func Test_ToStructDeep(t *testing.T) {
t.Assert(j.GetBool("items"), false)
t.Assert(j.GetArray("items"), nil)
m := new(M)
err = j.ToStructDeep(m)
err = j.ToStruct(m)
t.Assert(err, nil)
t.AssertNE(m.Me, nil)
t.Assert(m.Me["day"], "20009")