3

Currently, I am using JSON Path Extractor as my POST PROCESSOR to parse parameters from response body. Suppose say I have to parse two parameters from response 'AuthenticationToken' as well as 'userId'.

Do I have to add two 'JSON Path extractor' or what? If this is the solution then how should I parse if there are many parameters?

3 Answers 3

1

Yes, you can do it in one JSON Path Extractor.

I don't have access to JMeter right now, but here's an example on the linked page in the "Selecting Multiple Values with One Expression" section.

Additional reference on building JSONPaths.

Hope that helps.

1

You may use Regular Expression Extractor.

For example you want to get the token from

 data="user" token="asd23453453sad"> 

A regular expression would be

  data="user" token="(.+?)"> 
1

As Ravana said, you can do this with the built in JSON Extractor. You have to specify the same number of variable names as JSON Path Expressions. The names and expressions have to be separated by semicolons.

So, if you have a JSON structure like

{
 "userId": 23,
 "AuthenticationToken": "abc-123"
}

and want to extract those into the JMeter variables user_id and token, you would fill in variable names with

user_id;token

then you fill in JSON Path expressions with

$.userId;$.AuthenticationToken

and last you have to give default values for all your expected variables. So you fill in Default Values with something like

-1;"invalid token"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.