# Using JSONPath to validate numbers with specific initial digits

[JSONPath](/documentation/connectors-and-triggers/double-braces/double-braces-functions/json-functions.md) is a powerful tool for querying and filtering JSON data. It allows you to easily extract specific data from a JSON object or array, making it a valuable tool for developers and data analysts alike.&#x20;

In the following steps, you will learn how to use JSONPath to check whether a specific number starts with 0, 1, 2, or 3. This can be useful in situations where you need to filter out certain data or perform conditional operations based on the starting digits of a number.

## Validating numbers with JSONPath

To use JSONPath to check whether a number begins with 0, 1, 2 or 3, you can use the following expression:

```json
$[?(@.body.orderId =~ /^0.*/i || @.body.orderId =~ /^1.*/i || @.body.orderId =~ /^2.*/i || @.body.orderId =~ /^3.*/i)]
```

Let's break down this expression to understand how it works:

* `[ ]`: Used for filtering.
* `?`: Indicates a filter expression.
* `@.body.orderId`: Represents the path to the orderId field in the JSON structure.
* `=~`: Serves ad the regex match operator in JSONPath.
* `/^0.*/i`: Checks if the orderId starts with 0, 1, 2, or 3 (case-insensitive).
* `||`: Acts as  the logical OR operator, combining multiple conditions.

If the number meets this condition, it will be returned by the JSONPath query. Otherwise, it will be excluded from the results.

### Example

Let's say we have the following JSON data:

```json
{ "body": { "orderId": "12345" } }
```

Applying the JSONPath expression to this object would return a match, as the `orderId` (12345) starts with 1.


---

# Agent Instructions: 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:

```
GET https://docs.digibee.com/documentation/resources/best-practices/validation-json.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
