I have this JSON:
{
id : "12345",
videos: {
results: [
{
id: "533ec655c3a3685448000505",
key: "cYyx5DwWu0k"
}
]
}
}
And I want to unmarshal it to this struct:
type Film struct {
ID int `json:"id"`
Videos []Video `json:"videos"`
}
type Video struct {
ID string `json:"id"`
Key string `json:"key"`
}
I mean, I want to Videos
struct field to be videos.results
array.
If I do this:
body := //retrieve json above
var film Film
json.Unmarshal(body, &film)
obviously doesn't work because it can't unmarshal videos
json key to a Video
array because of results
key.
How can I do this?