According to https://gohugo.io/templates/data-templates/, JSON data can be accessed using .Site.Data.[filename].key
.
In the JSON world, the Key is sometimes part of the data, and we need to be able to retrieve the key name dynamically.
What syntax allows me to access the names of keys dynamically?
Here’s an example of a JSON fragment for a tournament score publication utility. The data has the competitor’s name as a key, and their scores as an array value.
comptition: [
{
"fred binkey": [12, 15, 28, 22, 3],
"joan watson": [30,29,23,21,28]
},
{
"sam clemens": [22,4,21,3,30],
"sherlock holmes": [29,28,30,30,26]
}
]
In my output, I want to show the name of the competitor, and then their scores.