这已经出现了很多次了。问题在于只能对导出的字段进行封送处理。
通过以大写(大写)字母开头来导出结构域。
type Animal2 struct { Name string Spec string Id uint32}在Go Playground上尝试一下。
请注意,JSON文本包含带有小写字母文本的字段名称,但是
json包足够“聪明”以匹配它们。如果它们完全不同,则可以使用struct标记来告诉
json程序包如何在JSON文本中找到它们(或应如何封送它们),例如:
type Animal2 struct { Name string `json:"json_name"` Spec string `json:"specification"` Id uint32 `json:"some_custom_id"`}


