在python中,你可以获取一个json对象并从中获取一个特定项而不声明一个结构,保存到一个结构然后获取像Go中的值.是否有一个包或更简单的方法来存储Go中的json特定值?
蟒蛇
res = res.json()
return res['results'][0]
Run Code Online (Sandbox Code Playgroud)
走
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)
}
Run Code Online (Sandbox Code Playgroud)