I read alot in the forum in this week but i still struggle with assertion and nested objects. There were good tutorials but i was not able to transfer the knowlage.
I’d like to read the value in the arrays like for accounting and consultation
This is a example of the body response:
The department objects has 8 arrays from 0 to 7.
I wrote a test but its “hardcode” not dynamic if something changes later.
I’d like to find the array by name = “marketing” or other name = “…”
my idea was using this structure which i found in the forum Assertions for API Test scripts
but it didn’t worked for my because in almost all of the 8 arrays is the name key.
for(let key in jsonData.office){
if(jsonData.office[key].**myproblem**('name=marketing')){
accountingValue = jsonData.office[key].name.tasks.accounting;
}
}
pm.test("value of accounting", function(){
pm.expect(accountingValue).to.eql(false);
});