Simply use a map if you don't know the key, and the value type of the map may be the struct describing the structure:
type mData struct {
KnownField1 [][5]int `json:"known_field_1"`
KnownField2 [][5]int `json:"known_field_2"`
KnownField3 [][5]int `json:"known_field_3"`
}
Note that you must export the fields for this to work!
And the unmarshaling code:
var data map[string]mData
if err := json.Unmarshal(body, &data); err != nil {
panic(err)
}
fmt.Println(data)
for k, v := range data {
fmt.Println(k, v)
}
Output (try it on the Go Playground):
map[unknown_field:{[[1 2 3 4 5] [10 20 30 40 50] [100 200 300 400 500]] [[11 21 31 41 51]] [[12 22 32 42 52] [14 44 34 44 54]]}]
unknown_field {[[1 2 3 4 5] [10 20 30 40 50] [100 200 300 400 500]] [[11 21 31 41 51]] [[12 22 32 42 52] [14 44 34 44 54]]}
See related questions:
How to parse/deserlize a dynamic JSON in Golang
Unmarshal JSON with unknown fields
Unmarshal json string to a struct that have one element of the struct itself
JSON Nested dynamic structures Go decoding