如何从外部包向结构添加自定义JSON封送处理?我无法将MarshalJSON和添加UnmarshalYAML到这些结构中。
您可以将该结构添加到您定义的结构中。然后添加功能MarshalJSON,并UnmarshalYAML给你的结构:
type YourStruct struct {
ImportedStruct
}
func (s *YourStruct) MarshalJSON() ([]byte, error) {
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
93 次 |
| 最近记录: |