The operators in this section are valid for maps.
Note: in addition to these operators, there is a membership infix operator that works on arrays and maps.
Many of the following operators take an argument that is a hash path. A hash path is an array whose elements represent the key values (for a map) or array indices of a path from the root of a complex data structure to the element of interest. For example, consider the following data structure:
The hash path
["foo", "bar"] references the following map inside the data structure:
delete() operator takes a hash path argument designating the member of the original data structure that should be deleted. The
delete() operator returns a new data structure with the specified member deleted. If the path is invalid, nothing is deleted and the new data structure is identical to the original. For example:
filter() operator takes a function as its only argument and returns a map. The new map contains any members of the original map for which the function evaluates to true. The function given as the argument must take two arguments and return a Boolean value. The function is applied to the key and value of each member of the map in turn. The number of elements in the new map will be less than or equal to the length of the original map. For example:
keys() operator returns the keys of the map to which it is applied. Without an argument, the keys at the top level of the map are returned. The operator also accepts a hash path argument. For example:
map() operator returns a map that contains the results of applying the function given as the operator's argument to each key-value pair from the original map. The function given as an argument must take two arguments: the first will be the value and the second the key. The result will be a map with the same keys, each key mapped to the result of the function. The length of the resulting map will be equal to the length of the target map. For example:
put() operator takes two arguments: an optional hash path, and a new element to be inserted. The result is a new data structure with the element inserted at the location specified by the hash path. If the path specifies a location that does not exist, it will be created. If the location already has a value, it will be replaced by the new element. For example:
If the hash path is omitted, the element must be a map, and its keys and values will be merged at the root level:
values() operator returns the values of the map to which it is applied. Without an argument, the values at the top level of the map are returned. The operator also accepts a hash path argument. For example: