Home > Net >  JMeter json path extractor and Regular expression combination
JMeter json path extractor and Regular expression combination

Time:12-24

I want to extract sys_id for the employee_number does not starting with "C"

{
    "items": [{
        "sys_updated_on": "2021-01-15 15:04:04",
        "sys_id": "60eaa1dc47870d9132f624846d434a",
        "employee_number": "C89"
    }, {
        "sys_updated_on": "2017-12-08 09:26:49",
        "sys_id": "c57058e8db8689ca52c4be13961974",
        "employee_number": "983"
    }, {
        "sys_updated_on": "2016-04-08 13:25:00",
        "sys_id": "fd413e848716119096ca2d0ebb358e",
        "employee_number": "565"
    }]
}

I tried multiple JSON Extractor expressions but no luck

$.[?(@.employee_number=~'\d ')].sys_id
$.[?(@.employee_number=~'[0-9]')].sys_id

Need both Xpath and Regular expression combination as the JSON contains many other fields and provided JSON is a small part of that.

I also want to know how to combine the regular expression and JSON path

CodePudding user response:

If you want to match only numbers in the employee_number - try out the following:

$.items[?(@.employee_number =~ /\d /)].sys_id

enter image description here

More information:

  • enter image description here

  • Related