title: POSTMAN: How to Check in Json response Array if a key:value exist
body: <p>I want to check in my JSON response <strong>Array</strong> if a key:value exists. 
  and <em>I want if the key:value is found <strong>get out from the loop</strong> and get the test result.</em> 
  Can you please support me how to do it? </p>
  
  <p>e.g. I have the following response:</p>
  
  <pre><code>[
      {
          "persID": "personID_1",
          "vip": false,
          "account": {
              "contactName": "value1",
          },
          "premium": {
              "Name": "value2",
              "Director": "value3",
              "company": "value7",
              "homePage": "value6",
              "address": {
                  "country": "value8",
                  "city": "value9"
              },
              "photo": value10
          }
      },
      {
          "persID": "personID_2",
          "vip": false,
          "account": {
              "contactName": "value11",
          },
          "premium": {
              "Name": "value12",
              "Director": "value13",
              "company": "value17",
              "homePage": "value16",
              "address": {
                  "country": "value18",
                  "city": "value19"
              },
              "photo": value110
          }
      },
      .....
      .....// dynamic response can be "n" elements!!!!
      ]
  </code></pre>
  
  <p>and I want to check if in this array a key value with (<strong>"persID": "personID_3"</strong>) exist.  (e.g. for persID_3, should the result be <strong>failed</strong>, and persID_2 <strong>passed</strong>) </p>
  
  <p>I have tried the following but no result:</p>
  
  <pre><code>var jsonArray = pm.response.json();
  var persID = "persID_3";
  pm.test("2. tets check if persdID exist in array", function () {
   var i=0;
   for(i; i&lt;jsonArray.length;i++){
  
                  pm.expect(jsonArray).to.have.property(jsonArray[i].persID, persID);
                  // pm.expect(jsonArray[i]).to.have.property(jsonArray[i].persID, persID);
  
   }
  });
  </code></pre>
  
  <p>Also tried with 
  var jsonArray = JSON.parse(responseBody);
  and
  pm.expect(jsonArray[i]).to.have.property(jsonArray[i].persID, persID);</p>
  
  <p>but no result</p>
  
  <p>Thanks for any Support.</p>