我是Utilities
的新手,并尝试使用golang
以这种格式创建json
golang
以下是我对{
"Title": "You are awesome",
"Url": "www.youareawesome.com",
"Desc": "your awesome desc is here",
"Payment": {
"Discount": "15%",
"outlets": [
{
"Location": "nowhere"
},
{
"Location": "everywhere"
}
]
}
}
的代码
struct
这就是我正在做的
type Partner struct {
Title string `json:"Title"`
URL string `json:"Url"`
Desc string `json:"Desc"`
Payment Payment `json:"Payment"`
}
type Payment struct {
Discount string `json:"Discount"`
outletList [] OutletItem `json:"outletList"`
}
type OutletItem struct {
Location string `json:"Location"`
}
我看不到付款对象中的出口阵列,我不确定是否错过了任何事情。
答案 0 :(得分:4)
OutletList
必须为大写
type Payment struct {
Discount string `json:"Discount"`
OutletList [] OutletItem `json:"outletList"`
}