import io.restassured.path.json.JsonPath; import io.restassured.response.Response;
Response response = RestAssured.get("https://example.com/api/users"); JsonPath jsonPathEvaluator = response.jsonPath();
//获取一个元素 String firstName = jsonPathEvaluator.get("data[0].firstName");
//获取所有元素
List
//使用断言检查特定元素是否存在 assertTrue(jsonPathEvaluator.get("data[0].id").equals("1234"));
given() .param("firstName", "John") .param("lastName", "Doe") .when() .get("https://example.com/api/users") .then() .statusCode(200);
下一篇:APIREST格式是否正确?