javarest-assured

total / count items from list json response


im trying to get count / total number of records from list api using Restassured.

Please share thoughts on how can we get it.

ex:

{
    "final list": [
        {
            "id": 123,
            "name": "sachin"
        },
        {
            "id": 234,
            "name": "sourav"
        }
    ]
}

I am expecting total as 2 here. please suggest.


Solution

  • I got answer to my question.

    here is the code for rest assured

    expect().body("final_list.findall.size()",equalTo(2)).when().get("/list.json);

    thanks