-1

Im using rest-assured and try to access the id's where condition liked = false matches with restassured jsonpath.

{
"data": {
    "content": [{
        liked=true,
        id=7fe9cb9a-51e9-e611-80bb-000c297d31d1
    },
    {
        liked=true,
        id=f60a496d-e5d1-e611-80ba-000c297d31d1
    },
    {
        liked=false,
        id=4fb4abfb-8ac3-e611-80ba-000c297d31d1
    }]
    }
}

The following code returns all the object, but i need only the id property list. How can i do that?

List<String> aa = response.get("data.content.findAll { content -> content.isLiked == false }");
szabieable
  • 133
  • 2
  • 13

1 Answers1

0

Using this solution returns only the required property with condition

    ReadContext rx = JsonPath.parse(resp.getBody().asString());
    List<String> asdf = rx.read("data.content[?(@.isLiked == false)].id");
szabieable
  • 133
  • 2
  • 13