Skip to main content
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

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.
The JSONPath syntax only supports the length function for arrays.