Hi guys.
Can anyone tell me how to write a test that will count how many objects I have nested in JSON in the response.
I don’t know the number, so “to.equal” is out of the question.
I would like Postman to return a number in the console.
PS.
I searched the forum, none of the answers worked.
Thanks!!!
Postman uses JavaScript, so I would recommend searching the web with JavaScript in the title.
You have an object called data, with an array of objects called ib_clients.
I assume you mean the number of objects in that array which you can use the array.length() method.
JavaScript Array length Property (w3schools.com)
const response = pm.response.json();
console.log((data.ib_clients).length);
This will return the number in the console logs, but I can’t see how you can craft an appropriate test for this unless you know what the expected number will be.
This works perfect 
var body = JSON.parse(responseBody);
tests["Array length is " + body.data.ib_clients.length] = true;

Thanks for Your support 