【发布时间】:2012-11-27 21:36:38
【问题描述】:
我有一个类似于这个的 JSON 对象:
{
"name": "Cain",
"parents": {
"mother" : "Eve",
"father" : "Adam"
}
}
现在我想将“name”和“mother”解析到这个结构中:
struct {
Name String
Mother String `json:"???"`
}
我想用json:... struct 标签指定JSON 字段名称,但是我不知道用什么作为标签,因为它不是我感兴趣的顶级对象。我在encoding/json 包文档或流行的博客文章 JSON and Go。我还测试了mother、parents/mother 和parents.mother。
【问题讨论】: