'Assert if value is present in any position of json array using pytest

I have a json array such as the one below:

{
   "employees":[
      {
         "name":"Shyam",
         "email":"[email protected]"
      },
      {
         "name":"Bob",
         "email":"[email protected]"
      },
      {
         "name":"Jai",
         "email":"[email protected]"
      }
   ]
}

When I am certain that the value 'Bob' would come at a certain position for example position 2, I can assert using :
assert json.loads(data)["employees"][2] == "Bob"

But, in my case, the value 'Bob' could be in any position of the array . In such case, how can I assert if the key 'name' and value 'Bob' are present in any position of the json array



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source