Maps#
Maps in CEL are unordered collections of key-value pairs. JSON objects are represented as maps with string keys.
Literals#
Create maps using curly braces with key-value pairs.
Keys can be strings, integers, unsigned integers, or booleans. Both keys and values can be heterogeneous.
Maps can be nested.
Size#
size() returns the number of key-value pairs.
Both function and method syntax are supported.
Access#
Access values using bracket notation with the key.
String keys also support dot notation.
Use bracket notation for keys that conflict with CEL reserved words.
Accessing a missing key produces a runtime error.
Membership#
The in operator checks if a key exists in a map.
Comparison#
Maps support equality comparison. Two maps are equal if they have the same keys with the same values.
See also#
- Lists - Ordered collections
- Protocol Buffers - Protobuf messages and enumerations