# How can i compare the same values found in the json formatted response

**URL:** <https://community.postman.com/t/how-can-i-compare-the-same-values-found-in-the-json-formatted-response/37054>\
**Category:** Help Hub\
**Tags:** tests, variables, collections, json, raw\
**Created:** [July 10, 2022, 5:52pm UTC](https://community.postman.com/t/how-can-i-compare-the-same-values-found-in-the-json-formatted-response/37054 "2022-07-10T17:52:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tugcesoydass](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tugcesoydass](https://community.postman.com/u/tugcesoydass)\
**Post date:** [July 10, 2022, 5:52pm UTC](https://community.postman.com/t/how-can-i-compare-the-same-values-found-in-the-json-formatted-response/37054/1 "2022-07-10T17:52:31Z")

</div>

Hi All,  
I sent request and got response. In this response all products were listed up. I am trying to get all same variables and check they are same or not. For example I need to check all " installment" are “true”. How could I write script for that.

{

“result”: {

“data”: {

“categoryName”: null,

“products”: [

{

“code”: “at773”,

“name”: “2 Dal Beyaz Orkide Çiçeği”,

“price”: {

“current”: 79.99,

“total”: 79.99,

“currency”: “TL”,

“currencyCode”: “TRY”

},

“installment”: true,

“installmentText”: “6 x 13,33 TL Taksit Seçeneği”,

“productGroupId”: 1,

“variantCode”: “at773-1”,

“deliveryChargeMessage”: “Ücretsiz Teslimat”

},

{

“code”: “at1742”,

“name”: “Büyülü Aşk 25 Kırmızı Güller”,

“price”: {

“current”: 69.99,

“total”: 69.99,

“currency”: “TL”,

“currencyCode”: “TRY”

},

“installment”: true,

“installmentText”: “6 x 11,66 TL Taksit Seçeneği”,

“productGroupId”: 1,

“variantCode”: “at1742-1”,

“deliveryChargeMessage”: “Ücretsiz Teslimat”

},

{

“code”: “at727”,

“name”: “Akvaryum Vazoda 7 Kırmızı Gül”,

“price”: {

“current”: 39.99,

“total”: 39.99,

“currency”: “TL”,

“currencyCode”: “TRY”

},

“installment”: true,

“installmentText”: “6 x 6,66 TL Taksit Seçeneği”,

“productGroupId”: 1,

“variantCode”: “at727-1”,

“deliveryChargeMessage”: “Ücretsiz Teslimat”

},

{

“code”: “at192”,

“name”: “Phalaenopsis Orkide Çiçeği”,

“price”: {

“current”: 69.99,

“total”: 69.99,

“currency”: “TL”,

“currencyCode”: “TRY”

},

“installment”: true,

“installmentText”: “6 x 11,66 TL Taksit Seçeneği”,

“productGroupId”: 1,

“variantCode”: “at192-1”,

“deliveryChargeMessage”: “Ücretsiz Teslimat”

},

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

---

<div class="post-metadata">

**Author:** ![archerZ](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@archerZ](https://community.postman.com/u/archerZ)\
**Post date:** [July 15, 2022, 7:59pm UTC](https://community.postman.com/t/how-can-i-compare-the-same-values-found-in-the-json-formatted-response/37054/2 "2022-07-15T19:59:24Z")

</div>

Hi @tugcesoydass

your test function should be like this.

pm.test(“Ensure installment is true”, function(){  
const jsonData = pm.response.json()  
jsonData.result.data.products.forEach(product =\> {  
pm.expect(product.installment).to.eql(true);  
});  
});

A few notes here. The issue you were having is you were not traversing down the object tree correctly See how i have “jsonData.result.data.products”. And secondly i am using a forEach loop so you can check all the installment value in the products list.
