Home > Back-end >  How do I use regular expression extractor in jmeter to extract a data from response data
How do I use regular expression extractor in jmeter to extract a data from response data

Time:05-05

I have a get api response data as

{"result code":"OK",
"result Obj":{
     "List": [
       {
           "Id" :123,
           "Name" : "abc",
            "Ran" : 345
        },
        {
           "Id" :987,
           "Name" : "poi",
            "Ran" : 657
        }
      ]
}
}

I want to use regular expression extractor to extract the name variable data from response(there are n names as such not fixed) so I can use it in the beanshell assertion to compare it later on.

Can you please show how to use regular expression extractor to extract the name variable and id variable separately for this and how to use that variable later on.

I have tried giving "Name":"(.*?)" As reg expression and template $0$ but it's not working properly

CodePudding user response:

  1. enter image description here

  2. Since JMeter 3.1 it's recommended to use JSR223 Elements and Groovy language for scripting so consider migrating to JSR223 Assertion

CodePudding user response:

I suggest to go with json extractor instead of regular expression extractor

  1. json expression : $..Name match case is 1

  2. Boundary extractor

left boundary:: "Name" : "

right boundary:: ",

  • Related