The error I’m getting proves that the getJSON part returns the correct data but I think it’s failing on the 2nd parameter to where
ERROR: 2016/03/15 error processing shortcode shortcodes/awards.html
ERR: template: shortcodes/awards.html:3:31: executing "shortcodes/awards.html" at <$.year>: year is not a field of struct type *hugolib.ShortcodeWithPage
WARN: 2016/03/15 &{map[year:1985] true}
ERROR: 2016/03/16 error processing shortcode shortcodes/awards.html
ERR: template: shortcodes/awards.html:3:30: executing "shortcodes/awards.html" at <.year>: year is not a field of struct type *hugolib.ShortcodeWithPage
WARN: 2016/03/16 &{map[year:1985] true}
Yes, that is a restriction with with. You will have to look at your JSON and see if you can refactor it or use parts of it that is a list and not a dictionary.
And just for completeness, this is the map version of what I was trying to achieve (where the JSON data is key-value instead of array), for example:
{
"1968": {
"awards": [
{
"award": "Club Person of the Year",
"recipients": [
"Winner Name"
]
}
]
}
}
{{ $year := .Get "year" }}
{{ $rally := (index $.Page.Site.Data.rallies $year) }}
{{ with $rally.awards }}
.. do something with awards if it exists
{{ end }}
and that can be distilled down to
{{ $year := .Get "year" }}
{{ with (index $.Page.Site.Data.rallies $year).awards }}
.. do something with awards if it exists
{{ end }}