增加Map MarshalJSON 方法

This commit is contained in:
2024-11-19 15:39:37 +08:00
parent db7bf0817e
commit 0d6d72b07e
2 changed files with 34 additions and 3 deletions

View File

@ -28,3 +28,20 @@ func TestMap_IsNil(t *testing.T) {
fmt.Println(m.Set("a", 1))
fmt.Println(m.IsNil(), m1.IsNil())
}
func TestMap_IsMasher(t *testing.T) {
var (
m Map
m1 = Map(map[string]any{
"a": 1,
"b": m,
"c": Map(map[string]any{
"name": "de",
}),
})
)
d, err := m.MarshalJSON()
fmt.Println(string(d), err)
d, err = m1.MarshalJSON()
fmt.Println(string(d), err)
}