> ## Documentation Index
> Fetch the complete documentation index at: https://docs.validio.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Semi-structured Data Syntax

> Learn the JSONPath syntax for accessing semi-structured and complex data structures using the Validio API, SDK, and CLI.

This article describes the syntax for accessing and navigating semi-structured data and other complex data structures using the Validio API, SDK, and CLI.

## JSONPath expressions

Validio uses JSONPath to handle semi-structured and other complex data types. Validio supports a subset of the JSONPath syntax.

This example shows nested data using JSON syntax:

```json title="JSON" theme={null}
{
   "agency":"MI6",
   "user":{
      "_id":"64591485781fd0a9e07be6c7",
      "name":"Valencia Walls"
   },
   "contact-info":{
      "company":"CONCILITY",
      "phone":"+1 (885) 535-3971",
      "address":"176 Visitation Place, 7052"
   },
   "friends":[
      {
         "id":0,
         "name":"Candy Diaz"
      },
      {
         "id":1,
         "name":"Sherry Burch"
      }
   ]
}
```

### Notation

You can use the dot `.` notation, bracket notation with single quotes `['...']` or double quotes `["..."]`, or a combination of both to form expressions. For example, the following expressions are equivalent:

`user.name`, `user["name"]`, `user['name']`, `['user']['name']` and `['user'].name`

Bracket notation is required when a field contains special characters, such as the hyphen `-`. For example, `['contact-info'].company` is a valid expression, but `contact-info.company` is not.

Valid characters in the dot `.` notation are alphanumeric characters, such as letters and digits, and underscore `_`. Identifiers that contain other characters require bracket notation.

Unlike most JSONPath dialects, the expressions *do not* begin with the optional dollar sign `$`, because an expression always starts from the root field, for example the column name of a warehouse table. This lets you use the same syntax in expressions for both nested and non-nested data validations.

For example, `agency` => `"MI6"` works the same regardless of whether the enclosing record contains nested fields.

### Arrays

Validio can perform validations on array fields and on objects nested within array fields.

The array subscript `[]` notation selects a specific element in an array. For example, the following expression selects the element with index `1` in the `friends` array field:

`friends[1].name` => `"Sherry Burch"`

The syntax supports functions on arrays with parentheses `()` at the end of an expression. For example, the following expressions are equivalent:

`friends.length()`, `friends['length']()` => `2`

The invoked function is the array length function, which returns the number of elements in the array.

> [!NOTE]
>
> The JSONPath syntax only supports the `length` function for arrays.
