Data extraction from response.Method 2

Second way to extra data from response is using Json extractor object.

Here we make an object of jsonextractor by applying jsonPath method to our response object

And then by using getString method on this jsonextractor object we can get values of all different nodes.

We need to add this import to our test class

import io.restassured.path.json.JsonPath;

Then we can extract data like in the example below.

JsonPath extractor = resp.jsonPath();
String firstName = extractor.getString("firstName");
String lastName = extractor.getString("lastName");