# Call jsonData in loop by passing parameters

**URL:** <https://community.postman.com/t/call-jsondata-in-loop-by-passing-parameters/14196>\
**Category:** Help Hub\
**Tags:** tests, variables, loop\
**Created:** [July 16, 2020, 8:43am UTC](https://community.postman.com/t/call-jsondata-in-loop-by-passing-parameters/14196 "2020-07-16T08:43:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nolan.lacroix1](https://avatars.discourse-cdn.com/v4/letter/n/6f9a4e/32.png) [@nolan.lacroix1](https://community.postman.com/u/nolan.lacroix1)\
**Post date:** [July 16, 2020, 8:43am UTC](https://community.postman.com/t/call-jsondata-in-loop-by-passing-parameters/14196/1 "2020-07-16T08:43:05Z")

</div>

Hello,

I have a problem that I cannot solve, even after several hours of research.

I want to pass a hash table. This must be called in a loop, and a test is performed : I check the body variables. The hash table key corresponds to this variable. The hash table value corresponds to the path to find this variable.

Body :

{  
“post code”: “90210”,  
“country”: “United States”,  
“country abbreviation”: “US”,  
“places”: [  
{  
“place name”: “Beverly Hills”,  
“longitude”: “-118.4065”,  
“state”: “California”,  
“state abbreviation”: “CA”,  
“latitude”: “34.0901”  
}  
]  
}

Test :

var jsonData = pm.response.json();  
const id = “id”;  
const expected = “expected”;

const complex\_arr=[  
{id:“country”, expected:“country”},  
{id:“longitude”, expected:“places[0].longitude”},  
{id:“state”, expected:“places[0].state”},  
{id:“latitude”, expected:“places[0].latitude”}  
]

for(i=0; i\<complex\_arr.length; i++){  
var actualId = complex\_arr[i].id;  
var actualExpected = complex\_arr[i].expected;

```
pm.test("Check " + actualId, function () {
    pm.expect(pm.variables.get(actualId)).to.equal(jsonData.actualExpected);
}

```

It is this last line that bothers me (jsonData.actualExpected). Indeed, jsonData is an object and i want to “concatenate” the jsondata with the variable path, which is a string. I tried to use some methods to succeed (ie. JSON.parse, JSON.stringify, concatenation, …) but nothing works.

Is it possible, and if so, can you enlighten me please?

Thanks !
