Artem Fedorov is a Java Developer at BlazeMeter. He specializes in writing plugins for JMeter. He also develops BlazeMeter plugins for Jenkins, TeamCity and Bamboo CI. Artem maintains and develops the Jenkins Performance Plugin.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Oct 15 2018

The New JSON/YAML Plugin - Using YAML in JMeter

The JSON Plugin was deprecated in Apache JMeter™ version 4, following the donation of the JSON Assertion component from to core JMeter. Now, I have updated this plugin to support new features and abilities. In this new version, the two plugin components, the JSON Path Extractor and the JSON Path Assertion have a new input format - YAML. So, users can choose between JSON and YAML input formats when running JMeter load tests. This provides more options and flexibility for performance testers - everything that was done before in JSON, can now also be done in YAML.


Let’s see how the JSON/YAML plugin works by generating a simple test plan. This test plan will take random values from two arrays (lists) in YAML and use them in a POST request as body parameters. The two arrays will be received from another request.


Let’s get started.


1. Add the JSON/YAML plugin to your JMeter with the JMeter plugins manager.


2. Add a Thread Group to your Test Plan.


3. Add a HTTP Request and configure the URL parameters. (In my example I will use a Dummy Sampler, because I want to show the response in a YAML format).


For this example, my server will return the following response in YAML. The data from this will be used to simulate the response from submitting a form on the BlazeDemo website.


      - Buenos Aires
      - Rome
      - London
      - Berlin
      - Boston
      - Milan
      - Paris
      - Moskow


the new json/yaml plugin


4. Add JSON/YAML Path Assertions


I added two assertions, that will check that my paths exist in the response. Each assertion has its own path:

  • $.tickets.departure.cities
  • $.tickets.destination.cities


5. Select the YAML Input Format in the assertion.


jmeter's json yaml plugin


6. Add JSON/YAML Path Extractors


I added two extractors that will extract two arrays to variables. Each extractor has its own path:

  • $.tickets.departure.cities[*] will extract to the variable ‘from’
  • $.tickets.destination.cities[*] will extract to the variable ‘to’


7. Select the YAML Input Format in the extractor.


running a yaml test in JMeter, open source


8. Let’s look at the extractor’s results. We can use the Debug Sampler and the View Results Tree listener.


jmeter, jmeter plugins, yaml script, json script


As you can see, the ‘from’ and ‘to’ variables show the full array from the YAML file. We also got the variables from_matchNr and to_matchNr that contain the size of each array. Finally, we see the set of variables from_* and to_* that contains each element from the arrays.


Now, let’s see how we can get a random value from these YAML arrays (in the results) and use it in a POST request as parameters.


9. Create a HTTP Request, fill in the body parameters (server, protocol, etc.) and set the parameters values according to the function you need. In this case:


  • Use random function ${__Random(1,${from_matchNr})}
  • Use __V function to evaluate nested variable references.
  • ${__V(from_${__Random(1,${from_matchNr})})}
  • Change the same for ‘to’ variable: ${__V(to_${__Random(1,${to_matchNr})})}


json/yaml plugin, jmeter, open source, tutorial


10. Now I can run my test script and look at the request bodies. You can see it has random values:


json/yaml plugin guide


That’s it! You can now use YAML inputs in JMeter, just like with JSON. Then, after creating your JMeter script, you can run it in BlazeMeter from multiple geo-locations, integrate with CI tools and get advanced reports. Start testing now: put your URL in the box below and your test will start in minutes.

arrow Please enter a URL with http(s)

You might also find these useful:

Interested in writing for our Blog?Send us a pitch!