如果将字段类型更改为指针,则可以区分空值和缺失值。如果该值存在于JSON中且带有空字符串值,则它将被设置为指向空字符串的指针。如果它不存在于JSON中,它将被保留
nil。
type Category struct { Name string Description *string}输出(在Go Playground上尝试):
[{Name:A Description:0x1050c150} {Name:B Description:<nil>} {Name:C Description:0x1050c158}]


