- 重新实现utils.Struct2FlatMap

This commit is contained in:
gazebo
2019-09-24 15:23:27 +08:00
parent 3ae979e48b
commit b02230ec2d
3 changed files with 42 additions and 37 deletions

View File

@@ -84,3 +84,40 @@ func TestTime(t *testing.T) {
}
}
}
func TestStruct2MapByJson(t *testing.T) {
type InnerKK struct {
IntData int
StrData string
ObjData time.Time
}
type KK struct {
IntData int
A int
B string
C time.Time
InnerKK
InnerKK2 InnerKK
}
kk := &KK{
InnerKK: InnerKK{
IntData: 1,
StrData: "hello",
},
}
mapData := Struct2MapByJson(kk)
t.Log(Format4Output(mapData, false))
// t.Log(mapData)
// t.Log(kk)
}
// func TestStruct2MapByJson(t *testing.T) {
// mapData := Struct2MapByJson(&struct {
// IntData int `structs:"dataInt"`
// StrData string `json:"-"`
// }{
// IntData: 1,
// StrData: "2",
// })
// t.Log(mapData)
// }