Is it possible to count the number of members using JsonPath?
Using Spring MVC test I'm testing a controller that generates
{"foo": "oof", "bar": "rab"}
with:
standaloneSetup(new FooController(fooService)).build()
.perform(get("/something").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(jsonPath("$.foo").value("oof"))
.andExpect(jsonPath("$.bar").value("rab"));
I'd like to make sure that no other members are present in the generated json. Hopefully by counting them using jsonPath. Is it possible? Alternate solutions are welcome too.
hamcrest-all
as a dependancy, but usehamcrest-library
: code.google.com/p/hamcrest/wiki/HamcrestDistributables – Internode