BLOCKS Reference

Common features

Get part of an array or object

This section explains how to get a part of the array or object data stored in a variable.

Arrays express multiple values in an ordered list, as shown in the image below. When a variable contains an array, you can reference the indices within the array to get parts of the data. Each value has an index showing its position, starting with index 0 in the first position of the array.

Example array data

Objects express data as a collection of key and value pairs, as shown in the image below. You can get a value from object data stored in a variable by referencing its corresponding key.

Object data example

You can create these kind of objects within BLOCKS using the Construct object BLOCK. These are also the same as the JSON objects that many BLOCKS use.

How to format

Format for arrays:
variable.index
Format for objects:
variable.key

info_outline When using the variable _ (the default variable in BLOCKS), you can omit the variable and simply write .index or .key

If the variable y contained the array shown in the image below, y.1 would get the value "API".

Array variable example

If the variable x contained the object shown in the image below, x.name (write keys without the ") would get the value "John Smith".

Object data variable example

Object data can also contain objects and arrays. To get data from an array or object within an object, use periods . to set off each nested layer. For example, variable.key.key or variable.key.index.

If the variable x contains the object shown above, x.languages.0 would get the value "English".

info_outline You can use this notation when using variable expansion (e.g., ${x.name} or ${y.1}).

この情報は役に立ちましたか?