【发布时间】:2021-03-25 16:53:25
【问题描述】:
我在 Go 中有一个来自 XML resp body 的结构:
{
"pdp":{
"sellableUnits":[
{
"attributes":[
{
"id":"22555278",
"type":"size",
"value":"03.5"
}
]
}
]
}
}
type sizeJ struct {
PDP struct {
SellableUnits []struct {
Attributes []struct {
ID string `json:"id"`
Type string `json:"type"`
Val string `json:"value"`
} `json:"attributes"`
} `json:"units"`
} `json:"pdp"`
}
根据 Val 的值有不同的 Vals 和不同的 ID。
【问题讨论】: