Updated February 21, 2023
Introduction to JMeter JSON Extractor
JMeter provides different functionality to the user, in which the JSON extractor is one of the functionality that JMeter provides. The JSON extractor is one tool used to execute the JSON expression path against the JSON responses, and it stores the output into the variable present in the JMeter. Normally JSON extractor is very easy to use, and we can easily implement it into the JMeter as per our requirement. Furthermore, using a JSON extractor, we can easily perform functional testing on the specified APIs because today’s all developers use different web services to access the API.
What is JMeter JSON extractor?
It is a convenient apparatus for executing JSON Path articulations against JSON reactions and putting the outcome into a JMeter Variable. On the off chance that the reaction of any solicitation is in JSON, we can utilize this extractor.
In JMeter, JSON (JavaScript Object Notation) Extractor is utilized to extricate the qualities from JSON reaction. JSON is a straightforward text that trades data between the customer and the server. It is composed of JavaScript objects; because of incrementally the REST APIs, the JSON is utilized as a basic information trade design. Therefore, you can get actual and valuable data on JSON at this site.
When you want to remove the qualities from the JSON reaction and pass them into another solicitation in the JMeter script, you can utilize JSON Extractor. It is a post-processor. We realize the post-processor pursues getting the reaction from the server and afterward plays out the errand like removing the unique worth and so on JSON extractor acts similarly.
How to add JMeter JSON extractor?
Now let’s see how we can add the JSON extractor to the JMeter.
First, we need to add the JSON Plug-in into the JMeter; add plug-in option is available in the options menu, as shown in the following screenshot.
Now download JMeter JSON Path Plugin and restart the JMeter; now click on the Options menu; inside the options menu, we have the plugins manager option. Next, we must select the available Plugin and the JSON Plugins option in this tab.
It is a convenient apparatus for executing JSON Path articulations against JSON reactions and putting the outcome into a JMeter Variable. On the off chance that the reaction of any solicitation is in JSON, we can utilize this extractor.
For adding a JSON extractor, we need to follow some steps.
- First, we must select any sampler element whose response has the JSON value.
- In a second step, we need to right-click on the selected sampler.
- Now move the cursor on the Add potion.
- Here we got the Post Processors option.
- Finally, we got the JSON extractor option to click on it.
All the above steps we illustrated by using the following screenshot as follows.
JMeter JSON extractor input
Now let’s see what input we require to implement the JSON extractor.
- Name: It is used to define the name of the post-processor.
- Comments: if you want to provide the comments, this depends on the user.
- Apply to: To characterize the pursuit of dynamic worth.
- Principle test and sub-examples: if the solicitation is diverted, then utilize this search scope so that necessary JSON worth can be examined in the reaction of both fundamental and coordinated solicitation.
- Principle test as it were: When the solicitation isn’t re-coordinated, or JSON esteem is available just in the reaction of the direct solicitation, then, at that point, utilize this search scope.
- Sub-examples as it were: When the solicitation is pre-coordinated, and required JSON esteem is accessible in the reaction of re-coordinated solicitation, then you can utilize this search scope.
- JMeter Variable Name to utilize: If JSON esteem should be separated from the worth of any JMeter variable, then you want to choose this choice and give the JMeter Variable name in the text field.
- Name of made variable: The name of the factors in which required JSON esteems will be put away. These are designated “JSON Extractor factors”. Utilize a semicolon to isolate the names of the factors that will contain the consequences of JSON-PATH articulations. The number should match the quantity of JSON-PATH articulations.
- JSON Path Expressions: The JSON way articulation needs to be composed here. You can compose more than 1 JSON way articulation which a semi-colon would isolate. The JSON factors and JSON way articulations are adjusted so that the first worth is distributed all the time to the primary variable.
JMeter JSON extractor examples
Now let’s see examples of JSON extractors for better understanding as follows.
First, we need to add an HTTP sampler request with sample rest API, as shown in the following screenshot.
We need to add a listener to the Thread Group to see the result, as shown in the following screenshot.
Now we need to execute the Thread Group, and after execution of the Thread Group, we can see the result in the view result tree as shown in the following screenshot.
As shown in the following screenshot, we need to add the JSON extractor to extract JSON value.
Here we need to assign the name, comment, variable name, and match number to our requirements. After that, we need to click on the Step-by-Step Debugger command, as shown in the following screenshot.
Here we got the new screen; click on the start and see the result shown in the following screenshot.
Conclusion
We hope you learn more about the JMeter JSON extractor from this article. From the above article, we have taken in the essential idea of the JMeter JSON extractor and see the representation and example of the JMeter JSON extractor. Furthermore, this article taught us how and when to use the JMeter JSON extractor.
Recommended Articles
This is a guide to JMeter JSON Extractor. Here we discuss the essential idea of the JMeter JSON extractor, and we also see the representation. You may also look at the following articles to learn more –