Performance testing

Learn more about continuous performance testing and how to deliver performance at scale.

Author:

Tricentis Staff

Various contributors

Date: Aug. 03, 2020

JSON, or JavaScript Object Notation, is a lightweight, text-readable format used in many web applications. It has familiarities to programming languages, but with an easier-to-read format. It uses objects and arrays, with strings and values, to structure data in the file format. The form and structure of JSON are meant to replace XML and AJAX systems. Since it is so widely used and accepted for data handling, it is only natural to have a load testing tool that can easily support and collaborate with JSON. This is where Tricentis NeoLoad excels.

JSON makes it easy to handle data for web applications. Its structure allows it to be easily modified for an application, as well as for a load testing tool. Take the example below for data of a user:

{

“firstName”: “John”,

“lastName”: “Smith”,

“isAlive”: true,

“age”: 27,

“address”: {

“streetAddress”: “21 2nd Street”,

“city”: “New York”,

“state”: “NY”,

“postalCode”: “10021-3100”

},

“phoneNumbers”: [

{

“type”: “home”,

“number”: “212 555-1234”

},

{

“type”: “office”,

“number”: “646 555-4567”

},

{

“type”: “mobile”,

“number”: “123 456-7890”

}

],

“children”: [],

“spouse”: null

}

This format makes it easy to interchange data for other segments of info. This block of data might be referred to as an object, with an array of strings and values. It makes it easy for the application to parse and add new data. Commonly, JSON requests end with a “.json” extension and have the standard content yype: application/json.

How NeoLoad works with JSON

NeoLoad has powerful built-in features to detect JSON content and is customizable to work with other content types needing to be identified as JSON. It can parse JSON data structures and view content with XML parsers. This makes extractions and correlation much easier. Here is an example from a sample website that uses JSON structure to provide user info:

[ { “id”: 1, “name”: “Leanne Graham”, “username”: “Bret”, “email”: “Sincere@april.biz”, “address”: { “street”: “Kulas Light”, “suite”: “Apt. 556”, “city”: “Gwenborough”, “zipcode”: “92998-3874”, “geo”: { “lat”: “-37.3159”, “lng”: “81.1496” } }, “phone”: “1-770-736-8031 x56442”, “website”: “hildegard.org”, “company”: { “name”: “Romaguera-Crona”, “catchPhrase”: “Multi-layered client-server neural-net”, “bs”: “harness real-time e-markets” } ]

As you can see, it is difficult to read, so NeoLoad detects it as JSON, presenting a way for the user to see the data in a simplistic format, for instance:

[

{

“id”: 1,

“name”: “Leanne Graham”,

“username”: “Bret”,

“email”: “Sincere@april.biz”,

“address”: {

“street”: “Kulas Light”,

“suite”: “Apt. 556”,

“city”: “Gwenborough”,

“zipcode”: “92998-3874”,

“geo”: {

“lat”: “-37.3159”,

“lng”: “81.1496”

}

},

“phone”: “1-770-736-8031 x56442”,

“website”: “hildegard.org”,

“company”: {

“name”: “Romaguera-Crona”,

“catchPhrase”: “Multi-layered client-server neural-net”,

“bs”: “harness real-time e-markets”

}

]

NeoLoad goes even further when performing correlation, particularly, when handling JSON content. Let’s take a look at how NeoLoad views this same response when using the new JSONPath extractor:

When creating the extraction by using the picker, we are presented with the nodes within the JSON content. This allows powerful command over extracting specific nodes or values.

NeoLoad allows the parsing of the XML format to a tree view, allowing for specific data selection. If we wanted to extract the names of the users in this list, we could act by selecting via “name” node. By default, it will select the [0] referenced object for the “name” node (“Leanne Graham” in the example):

And, by further manipulating the data, we can extract ALL of the name values by changing the $[0].name expression to $[*].name to get an array of values, as the wildcard extracts all of the matching values:

At this point, all of the names are extracted and in a variety of values. Note you can also add a regular expression to this extraction to further parse the data before using it in a variable in a later request.

Putting it all together

NeoLoad, as a load testing tool, has powerful functions to help use and manipulate JSON content. It has features to detect and parse JSON structures, extracting values from them for later use to maintain a dynamic design approach with new data for each iteration. Together, NeoLoad and JSON make a great team, working to handle your application’s data, saving it dynamically during load testing.

The post was originally published in 2018 and was most recently updated in July 2021.

Performance testing

Learn more about continuous performance testing and how to deliver performance at scale.

Author:

Tricentis Staff

Various contributors

Date: Aug. 03, 2020

Related resources