- 重新实现utils.Struct2FlatMap
This commit is contained in:
@@ -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)
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user