這是我的代碼package mainimport ( "encoding/json" "log")type Data struct { Page int Pages int PerPage string Total int CountriesList []Country}type Country struct { Id string Iso string}func main() { body := []byte(`[ { "page": 1, "pages": 6, "per_page": "50", "total": 256 }, [ { "id": "ABW", "iso2Code": "AW"}]]`) items := make([]Data, 10) if err := json.Unmarshal(body, &items); err != nil { log.Fatalf("error %v", err) }}我嘗試解組一些 JSON 并收到以下錯誤: 錯誤 json:無法將數組解組為 main.Data 類型的 Go 值
- 3 回答
- 0 關注
- 208 瀏覽
添加回答
舉報
0/150
提交
取消