array()
Returns an array containing the results of evaluating multiple expressions in order.
Syntax
array(EXPR1[, EXPR2, ...])
Parameters
EXPR1, EXPR2, ...- Values or expressions to include in the array. One or more can be specified, with no limit on the number.
Description
The array() function evaluates all expressions passed as arguments and returns an array containing the results in order. Each element may be of a different type. Even if an individual argument is null, the array itself is still returned with null at that position.
Error codes
N/A
Usage examples
-
Combining multiple field values into a single array
json "{'a': 1, 'b': 2, 'c': 3}" | eval result = array(a, b, c) | # result: [1, 2, 3] -
Creating an array from a mix of constants and fields
json "{'name': 'alice'}" | eval result = array("hello", name, 42) | # result: ["hello","alice",42] -
NULL input
json "{'val': null}" | eval result = array(val, 1) | # result: [null,1]
Compatibility
The array() function has been available since before Sonar 4.0.