如何将自定义 JSON 封送处理添加到外部包的结构中?我无法添加MarshalJSON
and UnmarshalYAML
到这些结构。
您可以将该结构添加到您定义的结构中。然后添加功能MarshalJSON
and UnmarshalYAML
到你的结构:
type YourStruct struct {
ImportedStruct
}
func (s *YourStruct) MarshalJSON() ([]byte, error) {
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)