I cannot get accessing JSON either under the data directory or loading local JSON with the getJSON function to work.
Here is the attempt to access JSON from a data template:
`{{/* JSON */}}
{{ $json := index $.Site.Data.jaysawn "firstkey" }}
<h2>{{ $json }}</h2>
And here is the YAML version:
{{/* YAML */}}
{{ $yaml := index $.Site.Data.yammel "firstkey" }}
<h2>{{ $yaml }}</h2>`
Here is the JSON file data/yammel.json:
{
"firstkey": "firstvalue"
}
And here is the YAML file data/yammel.yaml:
"firstkey": "firstvalue"
When trying to access JSON from a data template, the index call fails with:
"error calling index: index of untyped nil"
Note that accessing the YAML works just fine.
When trying to access the JSON as a local file via getJSON, I get:
unexpected end of JSON input
I’ve tried putting the json file at the top level of the site directory, under the data dir, and other places, but always the same error.
Am I doing something wrong? Or is JSON just not working? I have a lot of data I need to access one way or another in templates, and the data is natively JSON. I could convert it to YAML with yq or similar, but it would add another step to an already lengthy process, so I’d rather not if I can get Hugo to read the JSON. Any thoughts or suggestions greatly appreciated!