Easy scripting of JSON applications with Apache JMeter

on 29 October 2015 AJAX, DEVOPS, JMETER, JMETER-PLUGINS, JSON, LOAD_TESTING, PERFORMANCE, PRODUCTIVITY and Tags: , , , , , , , , , with 1 comment

Update on 29th October 2015:

In october 2015, we decided to donate our JSON Plugin to Apache JMeter as we think JSON support is mandatory nowadays in any Load Testing solution.

Donation vote:

Donation was accepted on 21th october:

And integrated as part of :


JSON (JavaScript Object Notation) has become a standard nowadays in application development and you can find it nearly everywhere:

  • Mobile applications
  • Rest Webservices
  • No SQL databases (MongoDB, ElasticSearch …)
  • Multitude of Webapp frameworks

Whenever you want to load test an application that uses this format in its communication with server, you have the following possibilities illustrated in this interesting blog:

Unfortunately, these methods have the following drawbacks:

  • JMeter Regular Expression Extractor : JSON is not well suited for Regexp matching, this method is not maintainable and can be hard to implement whenever you want for example to get the 3rd occurrence of an element
  • JMeter JSON plug-in : The plugin is useful for basic JSON tests but whenever you have complex JSON structures that you need to work with you will see some limitations the use cases I will present in the blog will show
  • BeanShell Post Processor with external JSON library : This method needs programming skills, is verbose and less maintainable, and performances are not great and will depend on the written code.

In this blog I will present an alternative method using Ubik Load Pack Plugin for JSON.

Some Real life Use Cases:

Extracting in one shot multiple elements of a JSON

Take this sample JSON:


Suppose you need to extract the following fields to put them in a following request:

  • currentCASiteRestriction
  • startExerciseDate
  • endExerciseDate
  • needCalculation

This is as simple as this:


You can then use the JMeter variables this way:

  • ${currentCASiteRestriction}
  • ${startExerciseDate}
  • ${endExerciseDate}
  • ${needCalculation}

If no match is found, plugin will use the Defaults values you put in the values. This behaviour is the same as “Regular Expression Extractor”.

Working with a JSON block located in HTML

One of our customers had an application to test that contained JSON blocks within HTML. Hopefully our plugin eased his work through the following process:

  1. Take the following HTML response which contains :
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    var jsonData = {...};
  2. To work on JSON data, we will first extract JSON data in JMeter variable then use our plugin to extract through JSON PATH expression the required data:ULP_TREE1
  3. Use core “Regular Expression Extractor” to extract the JSON block in a variable called “data” in this example:RegexpJSON1
  4. Use our ULP_JSON PostProcessor to extract from the JSON data the elements we want using the variable “data” extracted by previous Post-Processor:ULP_JSON_1

Working with all occurences of an element

Suppose you have this JSON:


And you need to run a request for each occurrence of “author”.

This is as easy as adding this Post Processor :


You can then use a ForEach Controller to iterate over “authors” variable:


You end up with this plan structure:



As you can see in the previous examples, using Ubik Load Pack plugin for JSON can help you speed up your testing with JSON thanks to:

  • No coding skills needed
  • Features that meet complex requirements
  • “JMeter” like philosophy which makes plugin very easy to use, no specific training needed
  • Very competitive pricing

So try it ASAP here.

About the author:

Philippe Mouawad works as an Architect and technical expert for Ubik-Ingenierie where he leads among other things the development of UbikLoadPack a set of Commercial Plugins for Apache JMeter allowing to load test different protocols like HLS, GWT, Flex.
Philippe is a committer on the Apache JMeter project and member of the PMC since October 2011.
Finally he is a co-author of a french book on JMeter called Maîriser JMeter: Du test de charge à Devops.

About us:

1 Comment

Comments are closed.