sách gpt4 ăn đã đi

go - 外部包的自定义 JSON 编码(marshal)处理

In lại 作者:IT王子 更新时间:2023-10-29 01:52:09 24 4
mua khóa gpt4 giày nike

如何将自定义 JSON 编码(marshal)处理添加到来自外部包的结构?我无法将 MarshalJSONUnmarshalYAML 添加到这些结构中。

câu trả lời hay nhất

您可以将该结构添加到您定义的结构中。然后将函数 MarshalJSONUnmarshalYAML 添加到您的结构中:

type YourStruct struct {
ImportedStruct
}

func (s *YourStruct) MarshalJSON() ([]byte, error) {
...
}

关于go - 外部包的自定义 JSON 编码(marshal)处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48412154/

24 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress