I am trying to parse the response body (JSON) which has multiple arrays nested within a larger array. I cannot figure out how to access the specific details within the furthest nested array. I want to confirm that all values of “Quantity” are greater than 20.
I have attached an image of the body (the 1st image) and the response body (the 2nd image).
For example: if one instance “Quantity” is 19, I want the test to fail
Hey, to be clear, you want accessForecastDetails and the Quantity of each SKU?
If you shared your Test script so we can see that would help, also try attaching the JSON request object or even just copy and paste it here so I can play with.
But trying to look I’d guess you could try to access it using:
let resp = pm.response.json();
//this would be for that single array
resp.ForecastDetails[0].ForecastWeeks[0].ForecastLines.filter(x => x.Quantity == 19);
You’d need to do a lot of looping for all the arrays. I just did what I could see based off the JSON object.
If you want to test against that I suppose you can loop in the expect in the test function.
Could you please help me on this issue
need to verify the values in the array T2, however the array T2 is dynamic in nature and the location of the array will change dynamically from (0,1), however the below test codes are not working in this case. Please see the below code. thanks