sankardev51
sankardev51

Reputation: 37

Get String value from JsonPath matching multiple conditions

jsonArray = "[{
        "id": "12",
        "Area": "Room",
        "Type": "Small",
        "mode": "Work",
    }, {
        "id": "243",
        "Area": "Hall",
        "Type": "Large",
        "mode": "Living",
    }, {
        "id": "561",
        "Area": "Kitchen",
        "Type": "Medium",
        "mode": "Cooking",
    }
]"

JsonPath ConfigPath = new JsonPath(jsonArray);

ConfigPath.get("d.findAll {d -> d.Area=='Room' && d -> d.Type=='Small'}.id");

How do I get the value of id that matches both the conditions?

I am using com.jayway.restassured.path.json.JsonPath

Upvotes: 1

Views: 937

Answers (1)

Arun Nair
Arun Nair

Reputation: 478

List<String> m1 = js1.get("findAll { d -> d.Area=='Room' && d.Type=='Small'}.id");
        System.out.println(m1);

Upvotes: 1

Related Questions