GCT1015
我制作了一个固定版本的代码(playground)。这似乎是主要的错误:type Char struct { ID int HP int CT int Stats []int // This was statList which won't work X int Y int ACList Actions}还要注意我所做的定义,Tile它允许数字为nil.type Tile struct { Depth int Type int Unit *int}你没有提供所有的结构,所以我做了一些 - 可能是错误的!总之就是:import ( "encoding/json" "fmt")type Match struct { Teams [][]Char Map [][]Tile ID string //uuid // Socket *websocket.Conn `json:'-'`}type Char struct { ID int HP int CT int Stats []int // This was statList which won't work X int Y int ACList Actions}type statList struct { Str int Vit int Int int Wis int Dex int Spd int}type Action stringtype Actions struct { Actions []Action TICKCT int}type Tile struct { Depth int Type int Unit *int}var data = `{"Teams": [ [ { "ID": 1, "HP": 10, "CT": 0, "Stats": [ 1, 1, 1, 1, 1, 1 ], "X": 0, "Y": 0, "ACList": { "Actions": [], "TICKCT": 0 } } ], [ { "ID": 2, "HP": 10, "CT": 0, "Stats": [ 1, 1, 1, 1, 1, 1 ], "X": 2, "Y": 2, "ACList": { "Actions": [], "TICKCT": 0 } } ]],"Map": [ [ { "Depth": 1, "Type": 1, "Unit": 1 }, { "Depth": 1, "Type": 1, "Unit": null }, { "Depth": 1, "Type": 1, "Unit": null } ], [ { "Depth": 1, "Type": 1, "Unit": null }, { "Depth": 1, "Type": 1, "Unit": null }, { "Depth": 1, "Type": 1, "Unit": null } ], [ { "Depth": 1, "Type": 1, "Unit": null }, { "Depth": 1, "Type": 1, "Unit": null }, { "Depth": 1, "Type": 1, "Unit": 2 } ]],"ID": "0b055e19-9b96-e492-b816-43297f12cc39"}`func main() { match := new(Match) err := json.Unmarshal([]byte(data), match) if err != nil { panic(err) } fmt.Printf("match = %#v\n", match)}