Working with JSON
Learn how to use JSON in your workflows.
Triggers and nodes in your workflows return data in JSON format. JSON data consists of key-value pairs, where the keys are strings and the values can be of various data types such as strings, numbers, booleans, objects, arrays, or null.
Nested JSON
Nested JSON refers to the structure where objects or arrays are nested within other objects or arrays. In other words, it is the inclusion of JSON objects or arrays as values within another JSON object or array. This nesting allows for creating hierarchical or complex data structures, representing relationships and organizing related data. Nesting can be done to multiple levels, enabling the creation of deeply nested JSON structures.
Working with nested JSON
Nested JSON is a JSON data with its values being other JSON objects.
With the help of JavaScript, you can access data in an object in an array in an object. It is referred to as nested data, which is how Actioner gets values from your triggers or other nodes in your workflows.
While working with JSON data in your workflows, there are two ways to access a nested object, through dot notation or bracket notation.
Dot notation is simply typing a dot .
at the end of an object and accessing the next object or property, such as
{{nodes.action0.response.body.object.key}}
Bracket notation is similarly typing a bracket [
at the end of an object and accessing the next object or property, such as
{{nodes.action0.response.body.object['key']}}
Actioner provides smart autocomplete to access the JSON while designing workflows.
When you have a JSON data and aren’t sure which fields, properties or methods you can access, go with the dot notation. In this case, dot notation is better than bracket notation since a [
will not bring up the autocomplete menu.
Accessing data in an object
Values in an object can be accessed using either dot notation object.key
or bracket notation object['key']
.
Below is an example response to action0
:
{
"tags":["user-management","payment-issues"],
"priority":"high"
}
Both examples below are evaluated as ["user-management", "payment-issues"]
nodes.action0.response.body['tags']
nodes.action0.response.body.tags
Accessing data in an array
Values in an array can be accessed using the index, or numeric location, of the target. The index always starts at 0, so the first element of an array can be accessed by using array[0]
.
Below is an example response to action0
:
{
"tags":["user-management","payment-issues"],
"priority":"high"
}
nodes.action0.response.body.tags[0]
returns user-management
in this example.