Reputation: 315
I'm trying to use Rest assured and JsonPath to extract a value from the pzSetRuleSetFilter field where the pyRuleSetName equals a certain value (TradeMarks in this case). I keep getting the error below. Any ideas on how I can fix this and extract the value would be great
invalid JSON expression:Script1.groovy: 1: expecting EOF, found '[' @ line 1, column 39.
My Query System.out.println(response.jsonPath().getString("$..pxResults[?(@.pyRuleSetName == 'TradeMarks')].pzSetRuleSetFilter"));
Sample JSON pxResults 0 pxClass Blah pyRuleSetName AValue pzSetRuleSetFilter 01-01-2000 1 pxClass Blah pyRuleSetName TradeMarks pzSetRuleSetFilter 01-02-2018 2
Upvotes: 0
Views: 417
Reputation: 959
You can directly use JsonPath provided by rest-assured and can use the following expression to get your desired output:
pxResults.find { it.pyRuleSetName == 'TradeMarks' }.pzSetRuleSetFilter
You can know more about Rest-Assured Json Path from here
Upvotes: 1