public interface ResponseBodyExtractionOptions extends ResponseBodyData
| Modifier and Type | Method and Description |
|---|---|
<T> T |
as(Class<T> cls)
Get the body and map it to a Java object.
|
<T> T |
as(Class<T> cls,
ObjectMapper mapper)
Get the body and map it to a Java object using a specific object mapper.
|
<T> T |
as(Class<T> cls,
ObjectMapperType mapperType)
Get the body and map it to a Java object using a specific object mapper type.
|
XmlPath |
htmlPath()
Get an XmlPath view of the response body that uses
XmlPath.CompatibilityMode HTML. |
JsonPath |
jsonPath()
Get a JsonPath view of the response body.
|
JsonPath |
jsonPath(JsonPathConfig config)
Get a JsonPath view of the response body using the specified configuration.
|
<T> T |
path(String path,
String... arguments)
Get a value from the response body using the JsonPath or XmlPath syntax.
|
XmlPath |
xmlPath()
Get an XmlPath view of the response body.
|
XmlPath |
xmlPath(XmlPath.CompatibilityMode compatibilityMode)
Get an XmlPath view of the response body but also pass in a
XmlPath.CompatibilityMode. |
XmlPath |
xmlPath(XmlPathConfig config)
Get an XmlPath view of the response body with a given configuration.
|
asByteArray, asInputStream, asString<T> T as(Class<T> cls)
as(Class, com.jayway.restassured.mapper.ObjectMapper).<T> T as(Class<T> cls, ObjectMapperType mapperType)
<T> T as(Class<T> cls, ObjectMapper mapper)
JsonPath jsonPath()
Assume that the GET request (to http://localhost:8080/lotto) returns JSON as:
{
"lotto":{
"lottoId":5,
"winning-numbers":[2,45,34,23,7,5,3],
"winners":[{
"winnerId":23,
"numbers":[2,45,34,23,3,5]
},{
"winnerId":54,
"numbers":[52,3,12,11,18,22]
}]
}
}
You can the make the request and get the winner id's by using JsonPath:
ListwinnerIds = get("/lotto").jsonPath().getList("lotto.winnders.winnerId");
JsonPath jsonPath(JsonPathConfig config)
config - The configuration to usejsonPath()XmlPath xmlPath()
Imagine that a POST request to http://localhost:8080/greetXML returns:
<greeting>
<firstName>John</firstName>
<lastName>Doe</lastName>
</greeting>
String firstName = get("/greetXML").xmlPath().getString("greeting.firstName");
XmlPath xmlPath(XmlPathConfig config)
config - The configuration of the XmlPathxmlPath()XmlPath xmlPath(XmlPath.CompatibilityMode compatibilityMode)
XmlPath.CompatibilityMode.
This is mainly useful if you want to parse HTML documents.compatibilityMode - The compatibility mode to usehtmlPath(),
xmlPath()XmlPath htmlPath()
XmlPath.CompatibilityMode HTML.
This is mainly useful when parsing HTML documents.
Note that this is the same as calling xmlPath(com.jayway.restassured.path.xml.XmlPath.CompatibilityMode) with CompatibilityMode HTML.
<T> T path(String path, String... arguments)
Note that you can also also supply arguments, for example:
String z = get("/x").path("x.y.%s", "z");
The path and arguments follows the standard formatting syntax of Java.
T - The return typepath - The json- or xml patharguments - Options argumentsjsonPath(),
xmlPath()Copyright © 2010–2014. All rights reserved.