title: Condition in Rest-Assured
body: <p>I am looking for a way to implement conditional verification in Rest Assured. Suppose if I get a response body as </p>
  
  <pre><code>{
  "id": 1,
  "accounts": [
    {
      "accountType": "Type1",
      "properties": {}
    },
    {
      "accountType": "Type2",
      "properties": {}
    }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>I have check for presence of "accounts" first. We can do that by </p>
  
  <pre><code>given().when().get("url").then().body().("any { it.key == 'accounts' }"), is(true))
  </code></pre>
  
  <p>Then I need to verify size of the accounts array if accounts exists in the response body. Is there any condition I can use here like</p>
  
  <pre><code>if(accountsExists) {Check for Array.size();} else {do something}
  </code></pre>