Reputation: 12342
Let's say I have following model:
@Data
class Model {
private String someField;
private String otherField;
}
And following JSON response in RestAssured:
{
wrapperField: {
someField: "some value",
otherField: "other value"
}
}
Is it possible to use extract().as()
construction in the nested path?
Something like:
getService().get("my-endpoint").then().extract("wrapperField").as(Model.class)
Upvotes: 1
Views: 1621
Reputation: 278
Have you tried something less elegant? Like that:
Response r = given()
.when()
.get(url)
.then()
.extract()
.response();
r.getBody().jsonPath().getObject("path", Model.class);
Upvotes: 2