【发布时间】:2022-04-19 16:31:33
【问题描述】:
在 python 中,您可以获取一个 json 对象并从中获取特定项目,而无需声明结构,保存到结构然后获取值,就像在 Go 中一样。有没有一种包或更简单的方法可以在 Go 中存储来自 json 的特定值?
蟒蛇
res = res.json()
return res['results'][0]
去
type Quotes struct {
AskPrice string `json:"ask_price"`
}
quote := new(Quotes)
errJson := json.Unmarshal(content, "e)
if errJson != nil {
return "nil", fmt.Errorf("cannot read json body: %v", errJson)
}
【问题讨论】: