您可以解码为
map[string]interface{},然后按键获取元素。data:= make(map[string]interface{})err := json.Unmarshal(content, &data)if err != nil { return nil, err}price, ok := data["ask_price"].(string); !ok { // ask_price is not a string return nil, errors.New("wrong type")}// Use price as you wish通常首选结构,因为它们对类型更明确。您只需要在所需的JSON中声明字段,而无需像使用映射(隐式编码/ json处理)那样键入assert值。



