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

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”

},

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.