getvalues
Prototype: getvalues(varref)
Return type: slist
Description: Returns the list of values in varref
which can be
the name of an array or container.
If the array contains list values, then all of the list elements are flattened into a single list to make the return value a list.
If the data container contains non-scalar values (e.g. nested
containers) they are skipped. The special values true
, false
, and
null
are serialized to their string representations. Numerical
values are serialized to their string representations.
You can specify a path inside the container. For example, below you'll
look at the values of d[k]
, not at the top level of d
.
Make sure you specify the correct scope when supplying the name of the variable.
Arguments:
varref
:string
, in the range:[a-zA-Z0-9_$(){}\[\].:]+
Example:
body common control
{
bundlesequence => { "example" };
}
bundle agent example
{
vars:
"v[index_1]" string => "value_1";
"v[index_2]" string => "value_2";
"values" slist => getvalues("v");
# works with data containers too
"d" data => parsejson('{ "k": [ 1, 2, 3, "a", "b", "c" ] }');
"cvalues" slist => getvalues("d[k]");
reports:
"Found values: $(values)";
"Found container values: $(cvalues)";
}
Output:
R: Found values: value_1
R: Found values: value_2
R: Found container values: 1
R: Found container values: 2
R: Found container values: 3
R: Found container values: a
R: Found container values: b
R: Found container values: c
Notes: