-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}]}]

我的代码的输出是

Number of list : 1 
max : [20]

我期待

Number of list : 5 
max : 20 // value should not be in []
4

1 回答 1

0

你可以尝试这样的事情:

System.out.println("列表个数:" +res.body().jsonPath().getInt("list.size()"));

于 2018-01-07T12:29:17.807 回答