Array To Map | ARRAY_TO_MAP

Syntax

ARRAY_TO_MAP( [value], [keyPath] )

Parameters

value
The ARRAY of MAP / OBJECT records being converted into a MAP.

keyPath
A path used to select the key for each entry in the resulting map. The key should probably reference to a value that is unique in each item, otherwise values may not be added to the resulting map. For more information on the path syntax used by instalink.io see the dedicated documentation on that subject.

Return Value

An MAP containing all the items in VALUE with the value at KEY used as the MAP key.

Description

Convert an ARRAY of OBJECT / MAP records into a MAP of those records using a path to get the key for each sub item in the result. This operation can, for example, be used to convert an ARRAY of records into a MAP where the keys in the map are the primary identifier of the record.

Examples

# VALUE is [
#   ["id" => "abc", "data" => 1], 
#   ["id" => "def", "data" => 2]
# ]
ARRAY_TO_MAP(VALUE, "id")
# returns [
#   "abc" => ["id" => "abc", "data" => 1], 
#   "def" => ["id" => "def", "data" => 2]
# ]