I have successfully parsed JSON into structs when they have a regular key-value format.
However, how can I parse a JSON like this:
{
"count": 2,
"results": [{ key: "workspaces", id: "10" }, { key: "workspaces", id: "11" }],
"workspaces": {
"10": {
id: "10",
title: "some project",
participant_ids: ["2", "6"],
primary_counterpart_id: "6"
},
"11": {
id: "11",
title: "another project",
participant_ids: ["2", "8"],
primary_counterpart_id: "8"
}
}
}
Where the keys for the workspaces
section is not defined ahead of time, but instead holds the workspace id?
My initial structs were:
type WorkspaceRequest struct {
Count int64 `json:"count"`
Workspaces []Workspace `json:"workspaces"`
}
type Workspace struct {
Title string `json:"title"`
}
How can I get a list of Workspaces from the shown JSON?