How do I get the array in a JSON via the key?

Hey there,

I’m new to HUGO and I think it’s pretty nice. So as written in the title I’m trying to extract an array out of a JSON via the key I will get from the markdown file (e.g. {{< infobox-content group="wallboxes">}})

First, my JSON:

{
    "wallboxes": ["ctest0", "test1", "test2"],
    "smart_plugs": ["ptest0", "test1", "test2"],
    "meters": ["mtest0", "test1", "test2"],
    "systems": ["stest0", "test1", "test2"],
    "vehicles": ["vtest0", "test1", "test2"]
}

And secondly the shortcode file:

{{ $group := .Get "group" }}
{{ $products := getJSON "/static/products.json" | jsonify }}
<p class="products group-{{$group}}">
    {{ range $products.$group }}
        {{ . }}
    {{ end }}

    group : {{$group}}
    {{ .Inner }}
</p>

So this definitely does not work. Would be great if someone has any suggestion how to do it.

what exactly comes out from {{ $products }} ? And have you tried removing the | jsonify ?

{{ $group := .Get "group" }}
{{ $products := getJSON "/static/products.json" }}
<p class="products group-{{ $group }}">
  {{ range index $products $group }}
    {{ . }}
  {{ end }}

  group : {{ $group }}
  {{ .Inner }}
</p>