Skip to main content
Version: Streamsheets 3.0

ARRAY

This function can be used to efficiently add array items to a message. Creates a JSON array entry using the given keys and values. If the range has one row or column, one array entry for each cell is created. If there are two columns or rows, a nested array (array containing a subarray) will be created. Note that if both nest and flat parameters are set to true one can use range instead.

Syntax

=ARRAY(Range, [Nest], [Flat])

Arguments

NameTypeDescription
RangeRangeSource Range to retrieve data from
Nest (optional)BooleanDirection on how to nest items, if range has more than one row or column. FALSE to nest by column and TRUE to nest by row. Default is TRUE.
Flat (optional)BooleanIf this Argument is supplied (any value works!) the returned Array is always nested, even if only one row or column is specified. If Argument is missing than the returned array is only nested if there are more than one row or column.

Return

TypeDescription
StringComma separated list of array items.

Examples

ABCDE
1Element1aElement2aNestNest
2Element1bElement2bFALSEFALSE
3Element1cElement2cFlatFlat
4Element1dElement2demptyTRUE
FormulaResultComment
=WRITE(OUTBOXDATA("Message", "NewItem"), ARRAY(A1:B4, FALSE), "Array")
Appending an array to a message. Since Nest is set to FALSE, the array items are created by columns leading to two array entries. The two entries contain the elements from the rows top to bottom. The message content will look as follows
=WRITE(OUTBOXDATA("Message","NewItem"), ARRAY(D1:D4,FALSE),"Array")
Example usage of the nested parameter.
=WRITE(OUTBOXDATA("Message","NewItem2"), ARRAY(E1:E4,FALSE,TRUE),"Array")
Example usage of the nested parameter.
tip

If you want to create an Outbox array step by step, you can use "-1" as last outbox data path to automatically add a new array element to the existing outbox message. =WRITE(OUTBOXDATA("Message";"data";-1);JSON(B1:C5);)