# How to display nested json data in visualizer

**URL:** <https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108>\
**Category:** Help Hub\
**Tags:** tests, visualizer\
**Created:** [December 15, 2022, 3:58pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108 "2022-12-15T15:58:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aazizhfc](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aazizhfc](https://community.postman.com/u/aazizhfc)\
**Post date:** [December 15, 2022, 3:58pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/1 "2022-12-15T15:58:37Z")

</div>

Hello,  
I have a simple end-point that returns basic information about classes. It has nested items in it. I implement the code to visualize the regular columns but I am not sure how to display the column with nested data.

{

```
    "Class": "BIO",
    "Start_Date": "11/09/2022",
    "End_Date": "12/09/2022",
    "Methods": [
        {
            "Inst_Method": "CC"
        },
        {
            "Inst_Method": "LAB"
        }
    ]
}

```

let template = `\< table bgcolor=“#FFFFFF”\>  
  
\< th\>Class  
\< th\>Start\_Date  
\< th\>End\_Date  
\< /tr\>

```
    {{#each response}}
        <tr>
            <td>{{Class}}</td>
            <td>{{Start_Date}}</td>
            <td>{{End_Date}}</td>
        </tr>
    {{/each}}
< /table>`;

```

// Set visualizer  
pm.visualizer.set(template, {  
// Pass the response body parsed as JSON as `data`  
response: pm.response.json()  
});

How do I display the “Methods” and its nested “Inst\_Method” data in one cell per row?  
Any help is appreciated. Thank you!  
Thank you.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 15, 2022, 6:47pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/2 "2022-12-15T18:47:59Z")

</div>

Does it only return one class at a time like in your example?  
If not, can you post an example with multiple classes.

If it does, then your logic is slightly wrong, as the for each will see the class, start date and end date as separate lines of data.

If it does only return one class at a time, then the following should work. (You can ignore the extra parsing that I needed to add to get Postman echo to replicate your example).

```auto
var template = `

    <style type="text/css">
        .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;}
        .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;}
        .tftable tr {background-color:#ffffff;}
        .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;}
        .tftable tr:hover {background-color:#e0ffff;}
    </style>
    
    <table class="tftable" border="1">
        <tr>
            <th>Class</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Methods</th>
        </tr>
        
        <tr>
            <td>{{response.Class}}</td>
            <td>{{response.Start_Date}}</td>
            <td>{{response.End_Date}}</td>

            <td>
                {{#each response.Methods}}
                    {{Inst_Method}}
                {{/each}}
            </td>
            
        </tr>

    </table>

`;

let json = pm.response.json().data
console.log(json);

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

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/3/c30b619afdad5204a17daa786cabdf972da29ecf.png)

---

<div class="post-metadata">

**Author:** ![aazizhfc](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aazizhfc](https://community.postman.com/u/aazizhfc)\
**Post date:** [December 15, 2022, 7:53pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/3 "2022-12-15T19:53:24Z")

</div>

Thank you mdjones,

It returns multiple classes at a time. The following is an example of multiple classes. Some of them have only one instructional method, other classes have multiple ones. I have seen one with 5 instructional methods.

[

{

```
    "Class": "BIO",
    "Start_Date": "11/09/2022",
    "End_Date": "12/09/2022",
    "Methods": [
        {
            "Inst_Method": "CC"
        },
        {
            "Inst_Method": "LAB"
        }
    ]

```

},  
{

```
    "Class": "ANTH",
    "Start_Date": "03/02/2022",
    "End_Date": "06/04/2022",
    "Methods": [
        {
            "Inst_Method": "CC"
        },
        {
            "Inst_Method": "OL"
        }
    ]

```

},  
{

```
    "Class": "MATH",
    "Start_Date": "04/03/2022",
    "End_Date": "06/05/2022",
    "Methods": [
        {
            "Inst_Method": "LAB"
        }
    ]

```

},  
{

```
    "Class": "CIS",
    "Start_Date": "10/09/2022",
    "End_Date": "12/09/2022",
    "Methods": [
        {
            "Inst_Method": "HYBRD"
        }
    ]

```

}

]

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 16, 2022, 10:07am UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/4 "2022-12-16T10:07:47Z")

</div>

This seems to work.

```auto
var template = `

    <style type="text/css">
        .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;}
        .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;}
        .tftable tr {background-color:#ffffff;}
        .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;}
        .tftable tr:hover {background-color:#e0ffff;}
    </style>
    
    <table class="tftable" border="1">
        <tr>
            <th>Class</th>
            <th>Start Date</th>
            <th>End Date</th>
            <th>Methods</th>
        </tr>
        
        {{#each response}}

            <tr>

                <td>{{Class}}</td>
                <td>{{Start_Date}}</td>
                <td>{{End_Date}}</td>

                <td>
                    {{#each Methods}}
                        {{Inst_Method}}
                    {{/each}}
                </td>

            </tr>

        {{/each}}

    </table>

`;

let json = pm.response.json().data
console.log(json);

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

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/f/1fedeead61fbd2539e66185d3778722bb51230e2.png)

---

<div class="post-metadata">

**Author:** ![aazizhfc](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aazizhfc](https://community.postman.com/u/aazizhfc)\
**Post date:** [December 16, 2022, 12:20pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/5 "2022-12-16T12:20:37Z")

</div>

Thank you. It is working now.

I appreciate it!

Best,  
Ali

---

<div class="post-metadata">

**Author:** ![aazizhfc](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aazizhfc](https://community.postman.com/u/aazizhfc)\
**Post date:** [December 16, 2022, 2:33pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/6 "2022-12-16T14:33:05Z")

</div>

One last thing, is it possible to freeze the header row in the “Visualize” tab while scrolling up and down? When scrolling it is difficult to keep track of what every column represents.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [December 16, 2022, 3:28pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/7 "2022-12-16T15:28:59Z")

</div>

Try the following in the CSS.

```auto
    <style type="text/css">
        .tftable {font-size:14px;color:#333333;width:100%;border-width: 1px;border-color: #87ceeb;border-collapse: collapse;}
        .tftable th {font-size:18px;background-color:#87ceeb;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;text-align:left;position:sticky;top:0;}
        .tftable tr {background-color:#ffffff;}
        .tftable td {font-size:14px;border-width: 1px;padding: 8px;border-style: solid;border-color: #87ceeb;}
        .tftable tr:hover {background-color:#e0ffff;}
    </style>`Preformatted text`

```

This is setting a sticky table header – `th { position: sticky; top: 0; }`

There can be issues with this approach, but see it if works.

---

<div class="post-metadata">

**Author:** ![aazizhfc](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@aazizhfc](https://community.postman.com/u/aazizhfc)\
**Post date:** [December 16, 2022, 6:52pm UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/8 "2022-12-16T18:52:13Z")

</div>

Thank you. This is perfect. The header becomes an overlay over the grid view.

Thanks again.

Ali

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 30, 2023, 9:48am UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/9 "2023-08-30T09:48:15Z")

</div>

Split this topic on August 30, 2023, 9:48am UTC

A post was split to a new topic: [Visualize Nested JSON Response Body](https://community.postman.com/t/visualize-nested-json-response-body/51149)

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [August 30, 2023, 9:45am UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/10 "2023-08-30T09:45:16Z")

</div>

@mission-cosmonaut-61

Potentially, but a) this should be its own question, not tacked onto a closed topic and b) what have you tried so far?

Can you also post more than one account in your example. (Include at least two please).

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 30, 2023, 9:49am UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/11 "2023-08-30T09:49:03Z")

</div>

Moved to its own topic and closing this topic out.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 30, 2023, 9:49am UTC](https://community.postman.com/t/how-to-display-nested-json-data-in-visualizer/42108/12 "2023-08-30T09:49:08Z")

</div>

Closed on August 30, 2023, 9:49am UTC


