Extract data from response and compare with json file

How can i extract and print only ‘brand_product_name’ from response body and compare that data with json/csv file.

Below is the response body:
{
“took”: 10,
“timed_out”: false,
“_shards”: {
“total”: 1,
“successful”: 1,
“skipped”: 0,
“failed”: 0
},
“hits”: {
“total”: {
“value”: 530,
“relation”: “eq”
},
“max_score”: 103.20297,
“hits”: [
{
“_index”: “product_completion_15_nov_2021_05_40_pm”,
“_type”: “_doc”,
“_id”: “1D7EJX0BMI9Ltk-jiRtD”,
“_score”: 103.20297,
“_source”: {
“product_code”: “0400014273450”,
“brand_product_name”: “Sportmax Hidalgo Wool Sheath Dress”,
“brandname”: “Sportmax”,
“product_name”: “Hidalgo Wool Sheath Dress”,
“refCategory”: “Clothing”,
}
},
{
“_index”: “product_completion_15_nov_2021_05_40_pm”,
“_type”: “_doc”,
“_id”: “8j7EJX0BMI9Ltk-jhQsk”,
“_score”: 103.09019,
“_source”: {
“product_code”: “0400014273327”,
“brand_product_name”: “Sportmax Dinar Belted Virgin Wool Trench”,
“brandname”: “Sportmax”,
“product_name”: “Dinar Belted Virgin Wool Trench”,
“refCategory”: “Clothing”,
}
},
{
“_index”: “product_completion_15_nov_2021_05_40_pm”,
“_type”: “_doc”,
“_id”: “Bz3EJX0BMI9Ltk-jd6dU”,
“_score”: 102.790016,
“_source”: {
“product_code”: “0400014575393”,
“brand_product_name”: “Sportmax Flavio Virgin Wool Sleeveless Dress”,
“brandname”: “Sportmax”,
“product_name”: “Flavio Virgin Wool Sleeveless Dress”,
“refCategory”: “Clothing”,
}
},
{
“_index”: “product_completion_15_nov_2021_05_40_pm”,
“_type”: “_doc”,
“_id”: “Zj3EJX0BMI9Ltk-jeLTr”,
“_score”: 102.3927,
“_source”: {
“product_code”: “0400014273409”,
“brand_product_name”: “Sportmax Kuens Crop Virgin Wool Jacket”,
“brandname”: “Sportmax”,
“product_name”: “Kuens Crop Virgin Wool Jacket”,
“refCategory”: “Clothing”,
}
},
{
“_index”: “product_completion_15_nov_2021_05_40_pm”,
“_type”: “_doc”,
“_id”: “cz7EJX0BMI9Ltk-jiBcO”,
“_score”: 102.3331,
“_source”: {
“product_code”: “0400015199322”,
“brand_product_name”: “Sportmax Pleated Denim Mini-Dress”,
“brandname”: “Sportmax”,
“product_name”: “Pleated Denim Mini-Dress”,
“refCategory”: “Clothing”,
}
}
]
}
}

Hey @chetan14cs!

Not quite sure if your response is of valid format.
One way to extract the brand_product_name is:

let jsonData=pm.response.json()

var hits=jsonData.hits
var hits_of_hits=hits.hits;

_.each(hits_of_hits, (item)=>{
 
    console.log(item._source.brand_product_name);

})

Good luck!

@bbahadur thank you :clap: