Back to Course
Rest Assured

Extracting Json Field Data From Response Using Restassured

Direct Assertions

.then().body("data.email", equalTo("janet.weaver@reqres.in"));

Extracting Into a Variable

String email = given()
    .when().get("/users/2")
    .then().extract().path("data.email");

Working With Arrays

List<Integer> ids = response.jsonPath().getList("data.id");

Why This Matters

Extracting specific fields is essential both for detailed assertions and for chaining values (like an ID or token) into subsequent requests.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course