JSONPath Builder is a helper utility used when creating REST API Active and Performance monitors, as well as REST API Active and Performance application monitoring (APM) components. This tool helps users select the JSON element they want to monitor, and generates a JSONPath Query for the selected JSON element.
The JSONPath Query can be written in two styles, bracket-notation and dot-notation, for example:
[‘name’]
$.name
This topic describes the workflow and supported syntaxes for the JSONPath Builder tool.
When you add a new REST API Performance Monitor from the Monitors Library, the Add REST API Performance Monitor window opens. This window contains two related sections, REST API and JSONPATH, that are used in the JSONPath Builder tool.
Provide a REST API Performance Monitor name, description, and timeout value, and then follow these steps to use the JSONPath Builder tool:
When you add a new REST API Active Monitor from the Monitors Library, the Add REST API Active Monitor window opens. This window contains two related sections, REST API and Down Condition, which includes the JSONPath Query grid as a method for adding down conditions for the monitor. The JSONPath Query grid makes use of the JSONPath Builder when you select the magnifying glass button.
While working with REST API Active Monitors, you can define multiple JSONPath Queries to evaluate a down state for the monitor. Also, unlike Performance Monitors, Active Monitors support validating down conditions against Numeric, Boolean, and String types of variables.
Upon selecting the JSON element in the JSONPath builder, the JSONPath Query grid automatically detects the type of the element, and inputs it in the Type column in the JSONPath Query grid.
Provide a REST API Active Monitor name, description, and timeout value, and then follow these steps to use the JSONPath Builder tool:
The REST API Performance application monitoring (APM) Component works similarly to the REST API Performance Monitor, with the addition of the Warning and Down threshold conditions for the numeric value response. A REST API APM Component can be attached to a test device and validated. The following image shows the example numeric API endpoint along with Warning and Down Threshold values:
The REST API Active application monitoring (APM) Component works similarly to the REST API Active Monitor, with the addition of a test device that the REST API Active APM component can be attached to and the monitor validated.
As mentioned above, the JSONPath Query can be written in two styles, bracket-notation and dot-notation, for example:
[‘name’]
$.name
If there was a JSON array of 'books' where the first item in the array had the name "The Cat in the Hat", you could access that value by entering either of the following JSON Queries:
[‘books’][0]['name']
$.books[0].name
In addition to support for generating JSONPath queries for JSON elements using the JSONPath Builder, you can also write advanced queries to validate the JSON response using filters in the JSONPath Queries. The filters can be used to perform operations using comparison operators. Additionally, the "length" property is available to return the length of a JSON array.
These properties can be used in the JSONPath Query filter to return values based on conditions and filter out values that are not required.
Note: The token selector will only return a value if the captured object is of length 1. A parsing error will be thrown if multiple values are returned by the JSONPath query.
Supported comparison operators are listed in the following table:
Comparison Operator Name |
Comparison Operator |
Example (Bracket-notation) |
Example (Dot-notation) |
Notes |
Equal to |
|
|
|
The query returns the number of copies of "The Cat in the Hat" in stock. |
Not Equal to |
|
|
|
|
Less than |
|
|
|
For Active Monitors and Active APM Components, the Down Condition would be a String that contains 'The Cat in the Hat', if "The Cat in the Hat" contained less than 3 copies, for example. |
Less than or equal to |
|
|
|
|
Greater than |
|
|
|
For Active Monitors and Active APM Components, the Down Condition could be a Number that does not contain 1 (the bookId of 'The Cat in the Hat'), if "The Cat in the Hat" contained more than 1 copy, for example. |
Greater than or equal to |
|
|
|
|
Length |
|
|
|
Returns the length of the JSON Array. |