# Visualizer: Getting a specific Nested Object. Same name, but different values

**URL:** <https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225>\
**Category:** Help Hub\
**Tags:** tests, json, visualizer, nested-array\
**Created:** [March 16, 2023, 6:49pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225 "2023-03-16T18:49:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelselley](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@michaelselley](https://community.postman.com/u/michaelselley)\
**Post date:** [March 16, 2023, 6:49pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225/1 "2023-03-16T18:49:49Z")

</div>

![Table](https://us1.discourse-cdn.com/getpostman/original/3X/2/3/2349c20aa1d1c59fde3ea78836fe941fecc090a2.png)Please community! Grace me with your wealth of knowledge. I’ve got hundreds of laptops I’m checking the warranty on through Dell’s API. The response returned looks like the one below. The visualize doesn’t give me the endDate either. The response is only on one machine for now, but the API lets me check up to 100 machines at once. The script for the visualizer is below it. I’m trying to build the visualize to only pull the “productLineDescription” “serviceTag” and a specific “endDate”. The problem for me there is that there are 3 different “endDates” listed under “entitlements”. I only want it to pull the 3rd one. I’d really like to get it to work so I can run 100 at a time.

[  
{  
“id”: 123456789,  
“serviceTag”: “POSLPTP”,  
“productLineDescription”: “LATITUDE 5590”,  
“entitlements”: [  
{  
“itemNumber”: “997-8328”,  
“startDate”: “2018-08-28T05:00:00Z”,  
“endDate”: “2019-08-29T04:59:59.999Z”  
“serviceLevelDescription”: “Onsite Service After Remote Diagnosis (Consumer  
Customer)/ Next Business Day Onsite After Remote Diagnosis (for business Customer)”,  
“serviceLevelGroup”: 5  
},  
{  
“itemNumber”: “984-1952”,  
“startDate”: “2018-08-28T05:00:00Z”,  
“endDate”: “2021-08-28T04:59:59.999Z”,  
“serviceLevelDescription”: “Keep Your Hard Drive/Keep Your Hard Drive for Enterprise  
Service”,  
“serviceLevelGroup”: 11  
},  
{  
“itemNumber”: “997-8332”,  
“startDate”: “2019-08-29T05:00:00Z”,  
**“endDate”: “2021-08-29T04:59:59.999Z”,**  
“serviceLevelDescription”: “Onsite Service After Remote Diagnosis (Consumer  
Customer)/ Next Business Day Onsite After Remote Diagnosis (for business Customer)”,  
“serviceLevelGroup”: 5  
}  
]  
}  
]

My Test Script in its original form. I’ve tried dozens of ideas, so I reset it back to the beginning.

var template =`  
  
.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;}  
.tftable

```
<table class="tftable" border="1">
    <tr>
        <th>Service Tag</th>
        <th>Product ID</th>
        <th>End Date</th>
    </tr>

    {{#each response}}
        <tr>
            <td>{{serviceTag}}</td>
            <td>{{productLineDescription}}</td>
            <td>{{endDate]}}</td>
        </tr>
    {{/each}}
</table>

```

`;

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

---

<div class="post-metadata">

**Author:** ![michaelselley](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@michaelselley](https://community.postman.com/u/michaelselley)\
**Post date:** [March 17, 2023, 2:13pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225/2 "2023-03-17T14:13:34Z")

</div>

Bump! I know there are some geniuses out there that can help.

---

<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:** [March 22, 2023, 3:20pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225/3 "2023-03-22T15:20:42Z")

</div>

Is it always the third result? Or can some devices have more or less entitlements?

If its always the 3rd object in the entitlement array, then the following should work.

{{entitlements.[2].endDate}}

The visualizer supports the Handlebars JS library.

[Handlebars (handlebarsjs.com)](https://handlebarsjs.com/)

The Handlebars treats the array slightly differently. I had to search on how to target the array because the normal ‘entitlements[2]’ was throwing errors.

```auto
let response = pm.response.json().data
// you can drop the .data (this is just how Postman echo returns the response)

console.log(response);

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;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>
    
    <table class="tftable" border="1">

        <tr>
            <th>id</th>
            <th>serviceTag</th>
            <th>endDate</th>
        </tr>

        {{#each response}}
            <tr>
                <td>{{id}}</td>
                <td>{{serviceTag}}</td>
                <td>{{entitlements.[2].endDate}}</td>
            </tr>
        {{/each}}

    </table>

`;

console.log(response);

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

```

---

<div class="post-metadata">

**Author:** ![michaelselley](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@michaelselley](https://community.postman.com/u/michaelselley)\
**Post date:** [March 22, 2023, 3:22pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225/4 "2023-03-22T15:22:06Z")

</div>

Ok I’ll give it a try! Thanks for the feedback. I’ll let you know.

---

<div class="post-metadata">

**Author:** ![michaelselley](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@michaelselley](https://community.postman.com/u/michaelselley)\
**Post date:** [March 22, 2023, 3:26pm UTC](https://community.postman.com/t/visualizer-getting-a-specific-nested-object-same-name-but-different-values/45225/5 "2023-03-22T15:26:50Z")

</div>

You have just made my day! Works exactly like I want. Thanks for the info on HandlBars JS library too.
