Reputation: 610
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.
Upvotes: 4
Views: 11262
Reputation: 610
OK I found it, needed to add apostrophes.
JsonPath.with(jsonResponse).get("findAll { a -> a.name == 'getName' }");
Upvotes: 7
Reputation: 8499
You need to set param. Try
JsonPath.with(jsonResponse).param("name", "getName").get("findAll { a -> a.name == name }")
Upvotes: 2