Skip to content

JMESPath Variable Extractor

JMESPath Extractors lets you extract values from HTTP JSON response bodies, using JMESPath expressions.

Extracting variables from HTTP response helps you make your Virtual User have a dynamic behavior. Extracted variables can be injected in Logic Actions or HTTP Request Actions.

JMESPath

Field Description
Name Name of the variable created by this processor. Can be used with the ${...} syntax like any other variable.
Usage Usage example of this variable. A click on Extracted variables opens the debug panel.
Path The JMESPath to be used. We recommend creating it with the configure button. The path can contain a variable.
Default value If no value is found, the variable will be equal to this. With match number All, you get the default value if you do not provide an index number.
Match number Lets you choose how to deal with the JMESPath having several results (or occurrences). Selecting All will change the behavior of your regex processor, see the dedicated section for more details.

Info

The response selector, on the right, lets you choose which HTTP response is used for configuring and checking the JMES Path Action. So if neither recorded responses nor Validate VU responses are available, you have to configure the JMESPath Action manually.

Configure

The configure button or the configure icon opens a new window in which you can use our JMESPath creator:

configure-json.gif

Tip

You can search for Strings or JMESPath Expressions inside the response body using the search fields in the table headers.

Debug

Simple

Opening the debug panel allows you to quickly see the result of your JMESPath. Make sure to check it every time you make a significant change:

debug-processor

Multiple occurrences

When the match number is set to all, the behavior of your JMES Path extractor changes.

Instead of a single variable, a lot of variables are created:

json-multiple-occurrence

Even if there is only one occurrence, the general structure of multiple occurrences extractions will always be:

  • WorkspaceName_N : the Nth value extracted,
  • WorkspaceName_matchNr : the number of values extracted, e.g. 4.

This means that you will have to provide an index when using this variable, typically the Foreach action or some functions are a good way to deal with this in a dynamic context.

Warning

Due to the way JMESPath is processed inside the underlying JMeter, Nodes of the same level may be extracted in a different order than what is displayed in OctoPerf. This shouldn't be an issue since the structure will be the same anyway.

Variable

It is possible to use another variable in the JMESPath. In that case make sure to specify the value of this variable in the debug panel in order to see the expected result:

json-path-variable

Example

For instance in a situation like this you might want to get all the workspace names in the list:

[
    {
        "id": "629WW7T4pwtaiecauWi4PasdaQruHr",
        "name": "Templates",
        "userId": "user-42"
    },
    {
        "id": "QMSQSdFVkcQ4q4ktTVqeYXS7nVvEy9",
        "name": "Shared Providers",
        "userId": "user-42"
    },
    {
        "id": "K62vyCX2cymazgFH2bfkju6eNKUTYR",
        "name": "Demo",
        "userId": "user-42"
    },
    {
        "id": "XQ4PVBN3w7tmzf9r2Az8KsDeK4q3EZ",
        "name": "This is a test",
        "userId": "user-42"
    }
]

To that end we can use one of the following JMESPath:

  • @
  • @[*]

For other examples and more resources check the JMESPath documentation.