# Comparing an array in a Json response

**URL:** <https://community.postman.com/t/comparing-an-array-in-a-json-response/25317>\
**Category:** Help Hub\
**Created:** [June 29, 2021, 2:26pm UTC](https://community.postman.com/t/comparing-an-array-in-a-json-response/25317 "2021-06-29T14:26:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerardovanegas620](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gerardovanegas620/32/6760_2.png) [@gerardovanegas620](https://community.postman.com/u/gerardovanegas620)\
**Post date:** [June 29, 2021, 2:26pm UTC](https://community.postman.com/t/comparing-an-array-in-a-json-response/25317/1 "2021-06-29T14:26:53Z")

</div>

I have this array set up from a previous GET response:

[85071929,85071930,85071979,85072029,85071899,85071900,85071901,85071902,85071903,85071904,85071905,85071906,85071907]  
This is set as a collection variable I setted up from a previous call

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

These are a set of Ids and I want to compare with the debtor.id of this response because if an ID from that list is not found I want to use it for a POST request

```auto
[
    {
        "objid": 26425,
        "holdRef": "AP",
        "debtor": {
            "id": 485922
        }
    },
    {
        "objid": 26426,
        "holdRef": "AP",
        "debtor": {
            "id": 490503
        }
    }
]

```

This is what I tried:

```auto
var jsonData = pm.response.json();
var debtorIds = pm.collectionVariables.get('debtorIds');

for (var i = 0; i < jsonData.length; i++) {
    for (var j = 0; j < debtorIds.length; j++) {
        if ( !JSON.stringify(jsonData[i].debtor.id).includes(debtorIds[j])){
            pm.collectionVariables.set('debtorForPost', debtorIds[j])
            break;
        }
    }
}

```

but I’m getting this: “[”  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/0/0f6d194dc8bc22b60435c83b91cb20d5737de95e.png)  
not sure what I should do, thanks in advance for your help!

---

<div class="post-metadata">

**Author:** ![gerardovanegas620](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gerardovanegas620/32/6760_2.png) [@gerardovanegas620](https://community.postman.com/u/gerardovanegas620)\
**Post date:** [June 29, 2021, 4:11pm UTC](https://community.postman.com/t/comparing-an-array-in-a-json-response/25317/2 "2021-06-29T16:11:28Z")

</div>

I solved my problem by parsing the Array variable as this  
var debtorIds = JSON.parse(pm.collectionVariables.get(‘debtorIds’));
