Postman - How to get value from json array

Hey @mission-saganist-751!

So, to get the benefitGeneralID from the response, we simply loop through the data, test for the required condition and save the required value,

One way to do this is:

//Saving the response from the GET request
var response=pm.response.json();
//Fetching the data array and storing it
var data=response.data, Ids=[];   //Ids to store benefitGeneralID

//looping through each data item
_.each(data, (item)=>{

    //Required condition
    if(item.uniqueCode==="name123code")
       Ids.push(item.benefitGeneralId);
})

console.log(Ids);

Good luck!

1 Like