> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/apis/assertion/jsonpath-match.md).

# JSONPath match

This is a pre-built action available under **@Assertion**. This Action validates whether the value extracted from the API response using a JSONPath expression matches the expected value. If the extracted value matches the expected value, the assertion passes; otherwise, it fails.

{% hint style="info" %}
**Note**: An API request must be added and executed successfully before configuring or evaluating API Assertions.
{% endhint %}

## Syntax

**Input Value**: `<JSONPath expression>;<JSONPath expected value>`

{% hint style="info" %}
**Note**: You can generate expressions automatically using the [Assertion expression builder](/avo-assure/actions/apis/assertion/jsonpath-match/assertion-expression-builder.md) available for the Response JSON Body. The generated expression can be used directly as the input for the JSONPath match action.
{% endhint %}

| Argument                                           | Description                                                                      |
| -------------------------------------------------- | -------------------------------------------------------------------------------- |
| <p>\<JSONPath expression></p><p>(Required)</p>     | Specify the JSONPath expression used to extract the value from the API response. |
| <p>\<JSONPath expected value></p><p>(Required)</p> | Specify the value to compare with the extracted value.                           |

**Output Value**: `<Actual value(optional)>;<Keyword Status(optional)>`

| Argument                                  | Description                                                                                                |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| <p>\<Actual value></p><p>(optional)</p>   | The actual value stores the value extracted from the API response using the specified JSONPath expression. |
| <p>\<Keyword Status></p><p>(optional)</p> | The keyword status variable stores the status as **True** or **False**.                                    |

## Example 1: Validating a JSON Value

In this example, we verify that a value extracted from the API response matches the expected value.

* **Action:** JSONPath match
* **Input Value:** $.company.name;TechsNova
  * The first part (**$.company.name**) specifies the JSONPath expression used to extract the value from the API response.
  * The second part (**TechsNova**) specifies the expected value.
* **Output Value**: {Actual Value};{Keyword Status}
  * The first output variable **{Actual Value}** stores the value extracted from the API response.
  * If the second output variable **{Keyword Status}** is defined, it stores the assertion result with the following possible values:
    * **True:** If the extracted value matches the expected value.
    * **False:** If the extracted value does not match the expected value.
* **Logical Explanation:** The **JSONPath match** action evaluates the JSONPath expression (**$.company.name**) against the API response and extracts the value **TechsNova**. The extracted value is stored in the **{Actual Value}** variable. The action then compares the extracted value with the expected value ("**TechsNova"**). If both values match, **{Keyword Status}** stores **True**; otherwise, it stores **False**.

![](/files/BYXAujEv2uZHpZqCTiX8)

## Example 2: Validating a Filtered JSON Value

{% hint style="info" %}
**Note**: To use a filter JSON expression, you must add it manually.
{% endhint %}

In this example, we verify the employee count for the branch located in Bengaluru using a JSONPath filter.

* **Action:** JSONPath match
* **Input Value**: $.company.locations.branches\[?(@.city=="Bengaluru")].employees;120
  * The first part (**$.company.locations.branches\[?(@.city=="Bengaluru")].employees**) specifies the JSONPath filter expression.
    * **?()** defines the filter expression.
    * **@.city=="Bengaluru"** filters the branch whose city is Bengaluru.
    * **.employees** extracts the employee count from the matching branch.
  * The second part (**120**) specifies the expected value.
* **Output Value:** {Actual Value};{Keyword Status}
  * The first output variable **{Actual Value}** stores the value extracted from the API response.
  * If the second output variable **{Keyword Status}** is defined, it stores the assertion result with the following possible values:
    * **True:** If the extracted value matches the expected value.
    * **False:** If the extracted value does not match the expected value.
* **Logical Explanation**: The **JSONPath match** action evaluates the filter expression against the API response and locates the branch whose city is **Bengaluru**. It extracts the corresponding employee count (**120**) and stores it in the **{Actual Value}** variable. The action then compares the extracted value with the expected value (120). If both values match, **{Keyword Status}** stores **True**; otherwise, it stores **False**.

![](/files/hdUGKWBU0wtuMTk4GYjM)

## Supported JSONPath Expressions

| Symbol          | Meaning                            | Example                          | Purpose                                                                   | Returns                 |
| --------------- | ---------------------------------- | -------------------------------- | ------------------------------------------------------------------------- | ----------------------- |
| $               | Root JSON                          | $                                | To reference the root of the JSON document.                               | Entire JSON object      |
| .               | Child property                     | $.company.name                   | To access a child property of a JSON object.                              | TechNova                |
| \['key']        | Property with spaces/special chars | $.company\[‘first name’]         | To access a property whose name contains spaces or special characters.    | John                    |
| \[0]            | Array index                        | $.branches\[0].city              | To access an element at a specific array index.                           | Bengaluru               |
| \[-1]           | Last array element                 | $.branches\[-1].city             | To access the last element in an array.                                   | Hyderabad               |
| \[0,1]          | Multiple indices                   | $.branches\[0,1]                 | To access elements at multiple specified array indices.                   | First & second elements |
| \[1:3]          | Array slice                        | $.languages\[1:3]                | To access a range of array elements.                                      | Subset of array         |
| \[0:5:2]        | Slice with step                    | $.languages\[0:5:2]              | To access array elements within a range using a specified step value.     | Every 2nd element       |
| \[\*]           | Wildcard                           | $.branches\[\*].city             | To access all elements in an array or all matching child properties.      | All city values         |
| .\*             | All child properties               | $.company.\*                     | To access all child properties of an object.                              | All child values        |
| ..              | Recursive descent                  | $..city                          | To recursively search for a property throughout the JSON document.        | Every city in JSON      |
| \[?(condition)] | Filter                             | $.branches\[?(@.employees>100)]  | To filter array elements based on one or more conditions.                 | Matching objects        |
| &&              | Logical AND                        | @.city=='A' && @.employees>100   | To combine multiple conditions where all conditions must be true.         | Both conditions true    |
| \|\|            | Logical OR                         | @.city=='A' \|\| @.employees>100 | To combine multiple conditions where at least one condition must be true. | Either condition true   |
| == != > < >= <= | Comparison operators               | @.employees>=100                 | To compare values within a filter expression.                             | Comparison              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/apis/assertion/jsonpath-match.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
