Data extraction from response.Method 1

There are various ways of reading response from server and retrieving data out of it.

We can use exract method to extract all first names as a list

ArrayList<String> firstNameLists = given().contentType(ContentType.JSON).log().all().get("/list").then().extract().path("firstName");

Or we can even get first name of a particular student. So for that we have to pass that student id in the get method instead of passing the entire list.

String firstName = given().contentType(ContentType.JSON).log().all().get("/12").then().extract().path("firstName");

We can extract other fields like lastName,programme,courses etc as well.

String firstName = given().contentType(ContentType.JSON).log().all().get("/12").then().extract().path("firstName");
String programme = given().contentType(ContentType.JSON).log().all().get("/12").then().extract().path("programme");
String email = given().contentType(ContentType.JSON).log().all().get("/12").then().extract().path("email");
ArrayList<String> courses = given().contentType(ContentType.JSON).log().all().get("/12").then().extract().path("courses");