Map
A Map contains values associated with keys. Each value in the Map can be accessed by its key and a typical example of Map use in Dynamo is Salesforce query results, which, while actually Data item values, behave like Maps with the record field names as keys and the field values as the values. Use an expression like ${map.key}
to get the value behind a key.
All the keys of a Map are always String-type values, but the value can be of any type - even another Map, adding another data structure layer - regardless of the types of other values in the Map. It is generally up to the logic using Maps to know what kind of values are hidden behind the keys.
Related commands
setMap & addMapEntry
These commands can be used to create Maps within the logic, or modify existing Maps.
Methods
containsKey(value) | Resolves into a Boolean telling whether the Map contains the specified key (true) or not (false). For example, the expression |
isEmpty() | Resolves into a Boolean telling whether the Map contains no entries (true) or has one or more entries (false). For example, the expression Using the shorthand form the expression becomes |
keySet() | Resolves into a Collection that contains all the keys of the Map. Useful if you'd like to loop through all the entries of a Map, as with the key you can also easily get the matching value. For example, the expression |
size() | Resolves into a Number representing the amount of key-value pairs in the Map. For example, the expression |
values() | Resolves into a Collection that contains all the values of the Map. Do note that getting the matching key for any of the values in the Collection is not possible. This method should be used with care, as Maps often contain different kinds of values behind their keys. It is highly recommended to only use this method on Maps constructed within the logic, all containing similar kinds of values. For example, the expression |