This site has been deprecated. Do not edit pages here. Please visit the new Pico Labs documentation.

Skip to end of metadata
Go to start of metadata

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

Hash Paths

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:


The 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:


The encode() operator returns a string containing the JSON representation of the data structure to which it is applied. For example:

The encode() operator takes an optional map as an argument containing options for encoding. 

canonicaltrue, falseprint keys in sorted order (creates canonical string)
prettytrue, falsepretty prints the encoding (newlines and indents) if true


The filter() operator takes a function as its only argument 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:


The 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:


The 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 key and the second the value. 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:


The put() operator takes two arguments: a hash path and a new element to be inserted. The element must itself be a map. The result is a new data a 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. For example:

If the first argument is missing (i.e. there is only one argument) then the path is take to be the root and the item is put at the root level of the map:


The 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: