Built-ins for hashes

keys

expr?keys

Returns a sequence that contains all the lookup keys in the hash. Note that not all hashes support this.

Example:

<#assign h = {"name":"mouse", "price":50}>
<#assign keys = h?keys>
<#list keys as key>${key} = ${h[key]}; </#list>  

produces this output:

name = mouse; price = 50;  

Because hashes do not define an order for their sub-variables in general, the order in which key names are returned can be arbitrary. However, some hashes maintain a meaningful order. For example, hashes created with the above {...} syntax preserve the same order as specified by the sub-variables.

values

expr?values

Returns a sequence that contains all variables in the hash.

Because hashes do not define an order for their sub-variables in general, the order in which key names are returned can be arbitrary. However, some hashes maintain a meaningful order. For example, hashes created with the above {...} syntax preserve the same order as specified by the sub-variables.