# How to get Json value from response when there is different array with same value

**URL:** <https://community.postman.com/t/how-to-get-json-value-from-response-when-there-is-different-array-with-same-value/17178>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [October 28, 2020, 6:55am UTC](https://community.postman.com/t/how-to-get-json-value-from-response-when-there-is-different-array-with-same-value/17178 "2020-10-28T06:55:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayaveljays](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jayaveljays](https://community.postman.com/u/jayaveljays)\
**Post date:** [October 28, 2020, 6:55am UTC](https://community.postman.com/t/how-to-get-json-value-from-response-when-there-is-different-array-with-same-value/17178/1 "2020-10-28T06:55:21Z")

</div>

Hi All, in the below mentioned response we have different array which same value pattern, i need to pass the the “processInstanceId” value from array which has " freitext == submission" to next request. i need a test script and pre requisite script for next resquest. need immediate help on this automation scenario

[  
{

```
    "processInstanceId": "c0afa9cd-120b-11eb-ae9a-0a580a5e1be9",

    "processDefinitionId": "6d2a164d-0261-11eb-ae9a-0a580a5e1be9",

    "processDefinitionName": "Policy Policierung Folgeverarbeitung",

    "invoiceNumber": null,

    "amount": null,

    "startTime": "2020-10-19T15:05:25.161+0200",

    "endTime": "2020-10-19T15:05:37.119+0200",

    "durationInMillis": 11958,

```

“businessKey”: null,

```
    "versicherungsnummer": "56000113141",

    "partnernummer": "XUKTDM",

    "organisationsnummer": null,

    "schadennummer": null,

    "freitext": "Cancelation, 17aef182-d885-40d1-af8f-fad9b31ac465",

    "zielgruppe": null,

    "sender": "GWPC",

    "eingangskanal": null,

    "callbackid": "17aef182-d885-40d1-af8f-fad9b31ac465",

   "status": "COMPLETED"

```

}  
{  
“processInstanceId”: “386dc8d9-1204-11eb-ae9a-0a580a5e1be9”,

```
    "processDefinitionId": "6d2a164d-0261-11eb-ae9a-0a580a5e1be9",

    "processDefinitionName": "Policy Policierung Folgeverarbeitung",

    "startTime": "2020-10-19T14:11:30.082+0200",

    "endTime": "2020-10-19T14:11:46.758+0200",

    "durationInMillis": 16676,

```

“versicherungsnummer”: “56000113141”,

```
    "partnernummer": "XUKTDM",

    "organisationsnummer": null,

    "schadennummer": null,

    "freitext": "Submission, 80b856c6-8da8-4e4f-86da-0f65bc1981c2",

   
    "callbackid": "80b856c6-8da8-4e4f-86da-0f65bc1981c2",

    "kontaktid": "25cef3aa-2502-4c7e-81df-579864e95b36",

   

    "status": "COMPLETED"

```

}  
]

---

<div class="post-metadata">

**Author:** ![jeevananthank](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jeevananthank/32/4075_2.png) [@jeevananthank](https://community.postman.com/u/jeevananthank)\
**Post date:** [October 28, 2020, 7:45am UTC](https://community.postman.com/t/how-to-get-json-value-from-response-when-there-is-different-array-with-same-value/17178/2 "2020-10-28T07:45:01Z")

</div>

Hi @jayaveljays  
Welcome to the community!

Please refer to [this](https://learning.postman.com/docs/writing-scripts/script-references/test-examples/#parsing-response-body-data) for parsing response response body and getting a value.

In your case you can simply write a for loop through the array of json objects inside the array and if freitext contains Submission, then find the value of processInstanceId and save it to postman environment variables (for example).

```
var response = pm.response.json();
for (var i=0; i < response.length; i++) {
 if(response[i].freitext.includes("Submission")) {
       pm.envinronment.set("ID", response[i].processInstanceId);
       break;
   }
}
```

---

<div class="post-metadata">

**Author:** ![jayaveljays](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jayaveljays](https://community.postman.com/u/jayaveljays)\
**Post date:** [October 28, 2020, 9:12am UTC](https://community.postman.com/t/how-to-get-json-value-from-response-when-there-is-different-array-with-same-value/17178/3 "2020-10-28T09:12:24Z")

</div>

Thank you so much @jeevananthank, I really appreciate your work. now i made it working.  
Thanks once again for your helping hand
