User Guide

Creating and Using Structures 129
Getting information about structures
To find out if a given value represents a structure, use the IsStruct function:
IsStruct(variable)
This function returns True if variable is a structure.
Structures are not indexed numerically, so to find out how many name-value pairs
exist in a structure, use the StructCount function, as in this example:
StructCount(employee)
To discover whether a specific Structure contains data, use the StructIsEmpty
function:
StructIsEmpty(structure_name)
This function returns True if the structure is empty and False if it contains data.
Finding a specific key and its value
To learn whether a specific key exists in a structure, use the StructKeyExists function:
StructKeyExists(structure_name, key)
If the name of the key is known in advance, you can use the ColdFusion function
IsDefined, as in this example:
<cfset temp=IsDefined("structure_name.key")>
But if the key is dynamic, or contains special characters, you must use the
StructKeyExists function:
<cfset temp=StructKeyExists(structure_name, key)>
You can also use the StructFind function to find a key and return its value, as in this
example:
<cfset keyvalue=StructFind(structure_name, key)>
Getting a list of keys in a structure
To get a list of the keys in a CFML structure, you use the StructKeyList function:
<cfset temp=StructKeyList(structure_name, [delimiter] )>
The delimiter can be any delimiter, but the default is a comma ( , ).
The StructKeyArray function returns an array of keys in a structure:
<cfset temp=StructKeyArray(structure_name)>
Note
The StructKeyList and StructKeyArray functions do not return keys in any
particular order. Use the ListSort or ArraySort function to sort the results.