rest-assured/src/main/java/io/restassured/builder/ResponseSpecBuilder.java
public ResponseSpecBuilder expectBody(String path, Matcher<?> matcher) {
        spec.body(path, matcher);
        return this;
    }
public ResponseSpecBuilder expectBody(String path, Matcher<?> matcher) {
        spec.body(path, matcher);
        return this;
    }
public ResponseSpecBuilder expectBody ( String path , Matcher < ? > matcher ) { spec . body ( path , matcher ) ; return this ; }
Expect that the JSON or XML response content conforms to one or more Hamcrest matchers.<br>
<h3>JSON example</h3>
<p/>
Assume that a GET request to "/lotto" returns a JSON response containing:
<pre>
{ "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]
}]
}}
</pre>
<p/>
You can verify that the lottoId is equal to 5 like this:
<pre>
ResponseSpecBuilder builder = new ResponseSpecBuilder();
builder.expectBody("lotto.lottoId", equalTo(5));
</pre>

@param matcher The hamcrest matcher that the response content must match.
@return The builder
Expect that the JSON or XML response content conforms to one or more Hamcrest matchers . <br > <h3 > JSON example< / h3 > <p / > Assume that a GET request to / lotto returns a JSON response containing : <pre > { 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 ] } ] }} < / pre > <p / > You can verify that the lottoId is equal to 5 like this : <pre > ResponseSpecBuilder builder = new ResponseSpecBuilder () ; builder . expectBody ( lotto . lottoId equalTo ( 5 )) ; < / pre >