0

I got json response as below where i need to extract the description value for my next POST method :

{

"description": "thisisjson"

}

I've tried using "description":"(.+?)" to extract but it is not working and returning me default value of error. Any idea on what i missing ? Thanks mySetting

3
  • Can you provide additional information on what extractor, the code or commands you are using? See also stackoverflow.com/help/mcve Commented Oct 28, 2017 at 6:46
  • You're missing a space after the colon in your regex. This sounds like very much The Wrong Way and you should use a json parser then extract the value. For example your regex will fail if the description is "hello \"there\"". Commented Oct 28, 2017 at 6:57
  • hi @user1620443 , i'm using regular expression extractor previously , but now it works fine with Json Extractor and Json Path expressions of : $..description instead . Thanks Commented Oct 28, 2017 at 6:57

2 Answers 2

2

If you want to use Regex Extractor:

  • "description": "([^"]+?)"

And configure it like this:

Regex Extractor

But for JSON it's better to use JMeter core JSON Extractor and enter:

  • JSON Path Expressions = $..description

JSON Extractor

Sign up to request clarification or add additional context in comments.

Comments

0

Use JSON Path extractor for extracting from JSON response.

JSON Path Extractor configuration

Variable Name: anyString JSON Path: $.description Default Value: NOT_FOUND 

Here is a screenshot from JSON Tester in JMeter

enter image description here

If you still want to stick to Regex Extractor than I guess what you missing is a space after : in the Regular Expression.

Use the following

Regex: "description": "(.+?)" 

Here is a screenshot from Regex Tester in JMeter

enter image description here

1 Comment

hi , i've just tried using Json Extractor instead and it works perfectly with : $..description thanks a lot

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.