ColdFusion structures consist of key-value pairs. Structures let you build a collection of related variables that are grouped under a single name. You can define ColdFusion structures dynamically.
You can use structures to reference related values as a unit, rather than individually. To maintain employee lists, for example, you can create a structure that holds
A structure key must be a string. The values associated with the key can be any valid ColdFusion value or object. It can be a string or integer, or a complex object such as an array or another structure. Because structures can contain any types of data, they provide a powerful and flexible mechanism for representing complex data.
Structure notation
ColdFusion supports three types of notation for referencing structure contents. The notation that you use depends on your requirements.
Notation |
Description |
---|---|
Object.property |
You can reference a property, prop, of an object, obj, as obj.prop. This notation, also called dot notation, is useful for simple assignments, as in this |
Associative arrays |
If you do not know the key name in advance, or it contains spaces, numbers, or special characters, you can use associative array notation. This notation uses structures as arrays with string indexes; for example: |
Structure |
Use structure notation only when you create structures and set their initial values, not when you are accessing or updating structure data, and only on the right side of an assignment expression. This notation has the following format: |