-4
@Test
public void getData() throws IOException {
    Response res = 
    given().
    header("authToken",userToken).
    when().
    get("/students").
    then().
    contentType(ContentType.JSON).
    extract().
    response(); 
    System.out.println("Number of list : " +res.body().path("list.size()"));
    System.out.println("max : " +res.body().jsonPath().get("max"));

}
[{"max":"20","list":[
{"id":1120,"sId":1120,"sIntId":"150","type":1},
{"id":1121,"sId":1121,"sIntId":"151","type":1}
{"id":1122,"sId":1122,"sIntId":"152","type":1}
{"id":1123,"sId":1123,"sIntId":"153","type":1}
{"id":1124,"sId":1124,"sIntId":"154","type":1}]}]

Output of my code is

Number of list : 1 
max : [20]

I was expecting

Number of list : 5 
max : 20 // value should not be in []
Erwin Bolwidt
  • 30,799
  • 15
  • 56
  • 79
Sunil
  • 1
  • Welcome to Stack Overflow. When you created your account here, it was suggested you take the [tour] and read the [help] pages in order to familiarize yourself with the site. Please do so, especially [ask], before posting your next question here. *Help me* and *Please advice* are not questions. – Ken White Jan 07 '18 at 02:50

1 Answers1

0

You can try something like this:

System.out.println("Number of list : " +res.body(). jsonPath().getInt("list.size()"));