title: How to search in anonymous and nested array using find or findAll in groovy's closures using REST-Assured library?
body: <p>I have following JSON response anonymous body and I need to parse nested arrays dynamically to retrieve a key's value based on a condition by using <code>find</code> or <code>findAll</code> in the groovy's closures</p>
  
  <pre><code>[
  {
    "children": [
      {
        "attr": {
          "reportId": "1",
          "reportShortName": "ABC",
          "description": "test,
        }
      },
     {
       "attr": {
         "reportId": "2",
         "reportShortName": "XYZ",
         "description": "test",
        }
     }
  }
  ]
  </code></pre>
  
  <p>I've tried the following ways and had no luck to retrieve the reportId key's value from the JSON response</p>
  
  <pre><code>package com.src.test.api;
  import static io.restassured.RestAssured.given;
  import io.restassured.path.json.JsonPath;
  import io.restassured.response.Response;
  
  public class GetReportId {
     public void getReportId(String reportName) throws Exception {
      String searchReports = "http://localhost:8080/reports";
      Response resp=given().request().when().get(searchReports).then().extract().response();
      JsonPath jsonPath = new JsonPath(resp.asString());
  
      String reportId1 =jsonPath.get("$.find{it.children.contains(restAssuredJsonRootObject.$.children.find{it.attr.reportShortName == 'ABC'})}.attr.reportId");
      String reportId2 = jsonPath.get("$.find{it.children.attr.reportShortName.contains(restAssuredJsonRootObject.$.children.find{it.attr.reportShortName.equals('XYZ')}.attr.reportShortName)}.attr.reportId");
      System.out.println("ReportId: " + reportId1);
    }
  }
  </code></pre>
  
  <p>There could be multiple JSON objects in the parent anonymous array and need to make use of find or findAll within the groovy closures to get the reportId</p>
  
  <p>Need to get the <code>reportId</code>, but seems that something is wrong.  Any help would be appreciated.</p>