1
votes

Using Regular Extractor in JMeter, I need to get the value of "fullBkupUNIXTime" from the below response,

{"fullBackupTimeString":["Mon 10 Apr 2017 14:14:36"],"fullBkupUNIXTime":["1491833676"],"fullBackupDirName":["10_04_2017_0636"]}

I tried with Ref Name as time and Regular Expression: "fullBkupUNIXTime": "([0-9])" and "(.+?)" and pass them as input for 2nd request ${time}

The above 2 two doesn't work out for me. Please Help me out of this.

2
Use this expression to retrieve fullBkupUNIXTime. You need to add escape character \ in the expression. \"fullBkupUNIXTime\":[\"(.+?)\"NaveenKumar Namachivayam
let me know if above answer works for you. I will post it in the answer. Thanks!NaveenKumar Namachivayam
I would suggest to get some additional insights about JMeter Regex Extractor by reading this guide on JMeter Regex Extractor. It gives some useful real-life examples.Jerome L
I have used JSON extractor for the above and it worked for me.GKalya

2 Answers

0
votes

First of all: why not just use this thing?

Then, if you firm with your RegExp adventure to get happen.

First expression is not going to work because you've defined it to match exactly one [0-9] charcter.

Add the appropriate repetition character, like "fullBkupUNIXTime": "([0-9]+)".

And basically it make sense to tell the engine to stop at first narrowest match too: "fullBkupUNIXTime": "([0-9]+?)"

Next, make sure you're handling space chars between key and value and colon mark properly. Better mark them explicitly, if any, with \s

And last but not least: make sure you're properly handle multiple lines (if appropriate, of course). Add the (?m) modifier to your expression. And/or (?im) to be not case-sensitive, in addition.

0
votes

[ is a reserve character in regex, you need to escape it, in your case use:

Regular Expression fullBkupUNIXTime":\["(\d+)

Template: $1$

Match No.:  1