I am trying to access a json file using a key extracted from another json file. Anybody to put me on track?
sample file 1: test_species.json
[
{
"name": "Autour des Palombes",
"species": "oiseau",
"scientific": "Accipiter gentilis",
"protections": ["EU","BE"]
},
{
"name": "Accenteur mouchet",
"species": "oiseau",
"scientific": "Prunella modularis",
"protections": []
},
{
"name": "Balbusard Pêcheur",
"species": "oiseau",
"scientific": "Pandion haliaetus",
"protections": ["EU","ES", "DE"]
}
]
sample file 2: test_protection_countries.json
{
"BE": {"country": "Belgique"},
"FR": {"country": "France"},
"ES": {"country": "Espagne"},
"PT": {"country": "Portugal"}
}
shortcode file
{{ $birds := .Site.Data.test_species }}
{{ $countries := .Site.Data.test_protection_countries }}
<div class="list_birds">
<ul>
{{ range $birds }}
{{ if eq .species "oiseau" }}
<li id="list_birds">
{{ .name }} (<i>{{ .scientific }}</i>)
{{ if gt (len .protections) 0 }} Prot:
{{ range $key, $value :=.protections }}
<!-- Pseudo code: $countries[$value] -->
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
</ul>
</div>