title: Rest Assured: extracting list of values from Json Response using java
body: <p>I have a JSON Response and want to extract list of values from response for e.g all the values of id's present.</p>
  
  <pre><code>{
  "page": 2,
  "per_page": 3,
  "total": 12,
  "total_pages": 4,
  "data": [
      {
          "id": 4,
          "first_name": "Eve",
          "last_name": "Holt",
          "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg"
      },
      {
          "id": 5,
          "first_name": "Charles",
          "last_name": "Morris",
          "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg"
      },
      {
          "id": 6,
          "first_name": "Tracey",
          "last_name": "Ramos",
          "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg"
      }
  ]
  }
  </code></pre>
  
  <p>I have tried below code but not able to achieve but it is only printing first value of id i.e 4.</p>
  
  <pre><code>public class Get_Request {
  
  public static void main(String[] args) {
  
      RestAssured.baseURI = "https://reqres.in/";
  
      Response res  = given()
        .param("page", "2")
      .when()
        .get("/api/users")
      .then()
        .assertThat()
        .contentType(ContentType.JSON)
        .and()
        .statusCode(200).extract().response();
  
      /*String data = res.jsonPath().getString("data[0].first_name");
  
      System.out.println(data);
      */
  
      List&lt;HashMap&lt;String,Object&gt;&gt; allids = res.jsonPath().getList("data");
  
  
      HashMap&lt;String,Object&gt; firstid = allids.get(0);
  
      Object a =  firstid.get("id");
  
      System.out.println(a);
  
  
      }
  }
  </code></pre>
  
  <p>I am beginner in rest assured also i am not sure whether we can achieve the same. Any help would be appreciated. Thanks in advance.</p>