Find the right object in array and assert on it

You could use something like:

let obj = pm.response.json().users.find(e => e.name === 'Julius');
console.log(obj.pet);

You could use that function inside a test and expect against obj.pet to equal iguana.

For example:

pm.test('Name of pet matches', () => {
    let obj = pm.response.json().users.find(e => e.name === 'Julius');
    pm.expect(obj.pet).to.eql('iguana');    
});
7 Likes