@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 []
答案 0 :(得分:0)
您可以尝试这样的事情:
System.out.println(“Number of list:”+ res.body()。jsonPath()。getInt(“list.size()”));