Reputation: 303
I need to extract user id from the below json response. But I should only extract user id when the absent attribute is "false".
"availableUsers":[ { "userId" : 6492, "workDate" : "08 07 2020 00 00 00", "workDay" : 6, "workShortName" : "1430-2330_RCO", "workTimes" : "14:30 - 23:30", "Layer" : 4, "earliestStartTime" : null, "latestEndTime" : null, "otaEntryAllowed" : false, "isDayLocked" : false, "isDayOff" : false, "TimeType" : "Overtime", "absent" : false, "comment" : "", }, { "userId" : 6493, "workDate" : "08 07 2020 00 00 00", "workDay" : 6, "workShortName" : "1430-2330_RCO", "workTimes" : "14:30 - 23:30", "Layer" : 4, "earliestStartTime" : null, "latestEndTime" : null, "otaEntryAllowed" : false, "isDayLocked" : false, "isDayOff" : false, "TimeType" : "Overtime", "absent" : true, "comment" : "", }]
Upvotes: 0
Views: 312
Reputation: 168217
In JsonPath there are Filter Operators therefore you can extract the userId
attribute value for the "absent" users as:
$.availableUsers[?(@.absent == false)].userId
Demo:
More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios
Upvotes: 2