RestAssured: How to check the length of json array response? : <p>I have an endpoint that returns a JSON like:</p>

<pre><code>[
  {"id" : 4, "name" : "Name4"},
  {"id" : 5, "name" : "Name5"}
]
</code></pre>

<p>and a DTO class:</p>

<pre><code>public class FooDto {
    public int id;
    public String name;
}
</code></pre>

<p>Now, I'm testing the length of the returned json array this way:</p>

<pre><code>@Test
public void test() {
    FooDto[] foos = RestAssured.get("/foos").as(FooDto[].class);
    assertThat(foos.length, is(2));
}
</code></pre>

<p>But, is there any way to do it without cast to FooDto array? Something like this:</p>

<pre><code>@Test
public void test() {
    RestAssured.get("/foos").then().assertThat()
      .length(2);
}
</code></pre>
