# Visualization - Iterating through object properties using {{#each}}

**URL:** <https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036>\
**Category:** Help Hub\
**Tags:** tests, visualizer\
**Created:** [February 26, 2020, 4:59pm UTC](https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036 "2020-02-26T16:59:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mloux](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mloux](https://community.postman.com/u/mloux)\
**Post date:** [February 26, 2020, 4:59pm UTC](https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036/1 "2020-02-26T16:59:09Z")

</div>

Hey folks,

I have managed to use the #each handlebars keyword to iterate through JSON arrays, but what if I wanted to iterate through the properties of an object (not an array) instead?

For example, say my response has an object “flags”, with a bunch of key/value pairs, basically. So, something like:

```
{
    "flags" : {
        "flag1": { /* nested properties */ },
        "flag2": { /* blah blah blah */ }
    }
}

```

Per some information I have seen on the handlebars site and forums, I should still be able to use {{#each response.flags}} and use {{@key}} for the key, and {{this}} to reference properties underneath the key.

However, when using a handlebars template in Postman, this does not appear to work. No rows are returned. I know that #each on objects was a later addition, but it appears to be in handlebars as of 2015, so it should work at this point.

Is the Postman implementation of these templates actually handlebars, or a roll-your-own thing?

Note - as a workaround, I can just use raw JS code and build the HTML table myself that way, using for (var key in response.flags), but I thought it would be nice to make use of templates where possible.

Thoughts, comments, suggestions?

---

<div class="post-metadata">

**Author:** ![mloux](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mloux](https://community.postman.com/u/mloux)\
**Post date:** [February 26, 2020, 7:33pm UTC](https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036/2 "2020-02-26T19:33:35Z")

</div>

Well, crap. I stumbled across the solution quite by accident while working on a standard array implementation. Seems that I simply failed to pass the response as a function call.

So instead of:

```
pm.visualizer.set(template, { response: pm.response.json() });

```

I was sending it as a value:

```
pm.visualizer.set(template, { response: pm.response.json }); // No parentheses after json.

```

Duh. Anyway, it works now. Hopefully others will #LFMF.

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [February 27, 2020, 6:21am UTC](https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036/3 "2020-02-27T06:21:32Z")

</div>

Not sure if you need it, but in case you were trying to visualize your response as a table, you can use this template to visualize any JSON/CSV response as a table (without writing any code - since it’s pre-written 😄):

[https://explore.postman.com/templates/3769/visualizer---any-jsoncsv-as-a-table](https://explore.postman.com/templates/3769/visualizer---any-jsoncsv-as-a-table)

---

<div class="post-metadata">

**Author:** ![mloux](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@mloux](https://community.postman.com/u/mloux)\
**Post date:** [February 27, 2020, 2:53pm UTC](https://community.postman.com/t/visualization-iterating-through-object-properties-using-each/11036/4 "2020-02-27T14:53:22Z")

</div>

I did see that pop up in search results. Haven’t tried any templates as of yet. Looks like as good a time as any to dive in. 🙂 Thanks!
