API URL : https://davids-restaurant.herokuapp.com/menu_items.json?category=C
I'm trying to retrieve name property of ID 913 from the above rest API
Please find my code below
String URL = "https://davids-restaurant.herokuapp.com/menu_items.json?category=C";
Response res = RestAssured.get(URL);
JsonPath jsonPathEvaluator = res.jsonPath();
System.out.println(jsonPathEvaluator.get("$..menu_items[?(@id == 913)].description"));
Error Message
java.lang.IllegalArgumentException: Invalid JSON expression:
Script1.groovy: 1: expecting EOF, found '[' @ line 1, column 40.
$..menu_items[?(@id == 913)].description
^
I tried this which works but I donot want to query with index but I want to query with ID
System.out.println(jsonPathEvaluator.get("menu_items[1].description"));