I'm extracting MailTM GET /domains API properties and need to extract the hydra:member
from the following API response.
{
"@context": "/contexts/Domain",
"@id": "/domains",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/domains/63d9a7067f7658e92f217bdd",
"@type": "Domain",
"id": "63d9a7067f7658e92f217bdd",
"domain": "eurokool.com",
"isActive": true,
"isPrivate": false,
"createdAt": "2023-02-01T00:00:00+00:00",
"updatedAt": "2023-02-01T00:00:00+00:00"
}
],
"hydra:totalItems": 1
}
I used JsonPath to extract the values from the response.
RestAssured.baseURI = "https://api.mail.tm";
Response response = given()
.when()
.get("/domains")
.then()
.extract().response();
response.body().jsonPath().get("hydra:member");
I can extract the other properties using JsonPath like @context
, @type
. But when I'm extracting the hydra:member
, I'm getting the following error.
You could put the key inside single quote ''
response.body().jsonPath().get("'hydra:member'");