# Looping keys from another list in template using getJSON \[solved\]

**URL:** <https://discourse.gohugo.io/t/looping-keys-from-another-list-in-template-using-getjson-solved/4465>\
**Category:** support\
**Created:** [November 2, 2016, 6:06pm UTC](https://discourse.gohugo.io/t/looping-keys-from-another-list-in-template-using-getjson-solved/4465 "2016-11-02T18:06:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sairam](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sairam/32/2198_2.png) [@sairam](https://discourse.gohugo.io/u/sairam)\
**Post date:** [November 2, 2016, 6:06pm UTC](https://discourse.gohugo.io/t/looping-keys-from-another-list-in-template-using-getjson-solved/4465/1 "2016-11-02T18:06:54Z")

</div>

I have a JSON field of properties in a dictionary

```auto
values = [{"property1": "value1", "property2": "value2"}, {"property1": "value11", "property2": "value12"}]

keys = {"property1": "Human Friendly Property name", "property2": "Better Name"}

```

I have the list of fields in an array. I want to iterate over the first array and use the key/value pairs in the second json to print data.

Can I access the key dynamically in a set dynamically?

```auto
{{ $data := getJSON "values.json" }} // does not have the "values = " in the file
{{ $header := getJSON "keys.json" }} // does not have the "keys = " in the file

{{ range $d := $data }}
  {{ range $key, $val := $header }}
    {{ with $header }}
      {{ $val }}: {{ $key }} // cant use $d.key or any other way.
    {{ end }}
  {{ end }}
{{ end }}

```

The output I am trying to achieve is

```auto
Human Friendly Property name: value1
Better Name: value2
Human Friendly Property name: value11
Better Name: value12

```

---

<div class="post-metadata">

**Author:** ![sairam](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sairam/32/2198_2.png) [@sairam](https://discourse.gohugo.io/u/sairam)\
**Post date:** [November 2, 2016, 6:50pm UTC](https://discourse.gohugo.io/t/looping-keys-from-another-list-in-template-using-getjson-solved/4465/2 "2016-11-02T18:50:19Z")

</div>

Solved it with `index`. Found `index` while looking at other problem in this forum 😌

```auto
{{ range $key, $val := $header }}
  {{ $val }}: {{ index $d $key }}
{{ end }}

```
