This content has been marked as final. Show 3 replies
> last struct in a nested struct
Strictly speakly, that doesn't exist. By default, Coldfusion does not sort the keys of a structure. The following code gives a sorted list of keys, some of which are themselves structures.
I wasn't looking for an alphabetical list, just trying to get to the inner most nested struct the quickest. In you example, how would I get the value of employee.phone.office.ext without previousley knowing that phone.office.ext existed and I only know about employee. I could iterate over it with some type of iterator hasNext(), but was wondering if there was a quicker way.
<cfset employee.name.first = "Mary">
<cfset employee.name.last = "Smith">
<cfset employee.position = "Boss">
<cfset employee.phone.home = "111-2222-33333">
<cfset employee.phone.office.ext = "444">
Oh, so you require the value of the "deepest" key(s) in the structure. The only method I know of is indeed to iterate across the keys/substructures, perhaps posing a question with isStruct() at every stage.