I have a scenario where a portion of the Parent API response is from a child API. If the child API response(which is dynamic) has only one array element then no need to match that in parent API response, if array size > 1
then I need to match from index 1 on wards with parent API response.
* def child = {"array1":[{"mbr1":{"id":"A1"}},{"mbr2":{"id":"A2"}}]}
There is no specific order for the child api response and array1
can have "n"
number of array elements(mbr1,mbr2,mbr3, etc)
If the child API response is like above then the parent will look like below:
* def parent = {"parent":{"muid":"1234"},"elg":[{"EID":"E123"},{"members":[{"mbr2":{"id":"A2"}}]}]}
So in parent API response towards the end child api response is populated, only if the above mentioned conditions are satisfied. If child API returns only one element then the parent API response will look like the below:
* def parent = {"parent":{"muid":"1234"},"elg":[{"EID":"E123"}]}
So how do I do a match to see whether the child is present in parent if child returns 200 OK and the child array length > 1? So I am looking for a solution for the below scenario:
if (child responseStatus == 200){
if (child.array1.length > 1){
for (i = 1;i <= child.array1.length; i++){
parent.elg[1].members[i] contains child.arrays1[i]
}
}
}