Data types

Supported data types

Overview

In order to support functions, a type system is needed. The JSON types are used:

  • string
  • boolean
  • null
  • number
  • datetime
  • array
  • object

There is also an additional type that is not a JSON type thatโ€™s used in JMESPath functions:

Data types

String

A data type used for representing text. Instances of strings are sequences of characters, including letters, numbers, punctuation and special characters. In JSON, strings are enclosed in double quotes "".

{
  "exampleString1": "test!",
  "exampleString2": "123.4"
}

Boolean

Boolean (sometimes shortened to Bool) is a data type that has two possible values (true and false) which represent the two truth values of logic and Boolean algebra. All other data can be assigned a truth value as well. This is especially useful when performing conditional operations on data.

{
  "bool1": true,
  "bool2": false
}

Null

A data type signifying the absence of any value. There's only one value of type null, also called null. Useful in case of missing data and evaluating expressions that fail to find data.

{
   "nullValue": null
}

Number

A data type used for representing numbers. It can be an integer (like 1, 2, or -3) or a floating-point decimal number (like 0.1, 2.5, or 3.14). A decimal point (".") is used, and commas are reserved for separating lines. Common mathematical operations are included as functions. The reference pages will specify if an integer or a float is required as input to a function.

As a rule, you can also count on strings that are correctly formatted as numbers (decimal point, possibly commas as thousands separators, no other symbols) to be valid input to numerical functions.

Sometimes, Boolean and null types are implicitly converted to numbers in functions requiring numerical input, like abs and add. In this case, true evaluates to 1.0, while false and null evaluate to 0.0. The way the functions act on these data types will be demonstrated in the examples.

{
  "a": 1,
  "b": -3.1
}

Datetime

Strictly speaking, datetime instances are strings that follow a specific format, but certain functions require a specific datetime input, or output a datetime object, so they're worth defining. A data type that represents an instant in time and allows simple conversion between time zones and time formatting standards.

{
  "a": "2022-10-07T13:20:00.9999999Z",
  "b": "2020-01-01T09:00:00.0000001Z"
}

Array

An ordered sequence of values of any data type. The values are called elements, and the number indicating the position of an element in the array is called an index. The index starts at 0, and ends at n-1, where n is the length of the array. Arrays organize data and make it possible to perform operations on many elements of the same type.

{
  "a": [0, 1, 2, 3],
  "b": ["apple", "pineapple", "mango"],
  "c": [true, null, "yes", 0],
  "d": [[0, 1, 2], [3, 4, 5], []],
  "e": [{}, {a: 1, b:2}]
}

Object

An unordered sequence of key-value pairs, where keys are strings and the values can be of any data type. A key is separated from its value by a colon, and different key-value pairs are separated by commas. The entire object is enclosed in curly brackets {}. You might notice that the examples of data types above are, in fact, objects with values of different data types. Objects introduce hierarchical organization of data. In some programming languages, similar data types are called dictionaries, because the keys roughly correspond to words, and the values to the definitions.

{
  "a": {"name": "Jason", "lastName": "Object"},
  "b": {"number": 6, "divisors": [1, 2, 3, 6]},
  "c": {
    "fruit": "peach",
    "delicious": true,
    "lastEaten": "2023-07-01T09:00:00.0000001Z",
    "color": {
    	"skin": ["red", "orange", "yellow"],
    	"flesh": ["yellow", "white"]
    }
  }
}

Syntax

Notice that, in JSON, the keys must be enclosed in double quotes. In Documotor's JMESPath implementation, that's not necessary, unless the key contains special characters or numbers. Besides that, see check out the Expressions page for more details about writing JMESPath code.

Learn more

  • not_null, the function that checks if an argument is null.
  • type, the function returning the type of an argument.