jsonpath find all object(restassured)

Michael Biniashvili picture Michael Biniashvili · Jul 31, 2014 · Viewed 7.6k times · Source

This is my JSON :

[
{
    "id": 9741962,
    "name": "getName",
    "isActive": true
},
{
    "id": 1,
    "name": "New",
    "isActive": true
}
]

I want to get all the object that has the name :getName using jsonPath how can I do it using JsonPath (the onw that comes with rest assured)

I try this one

JsonPath.with(jsonResponse).get("findAll { a -> a.name == getName  }");

but I am getting Error.

java.lang.IllegalArgumentException: No such property: sdfsdf for class: Script1

Thanks.

Answer

Michael Biniashvili picture Michael Biniashvili · Aug 3, 2014

OK I found it, needed to add apostrophes.

JsonPath.with(jsonResponse).get("findAll { a -> a.name == 'getName' }");