StructFindKey()
Searches recursively through a substructure of nested arrays, structures, and other elements, for structures whose values match the search key in the value parameter.
StructFindKey( Top=struct, Key=string, Scope=string );
Returns: Array
| Argument | Description | Default |
|---|---|---|
|
Top
struct,
required
|
edit
object from which to start search. This parameter requires an object, not a name of an object. Alias: struct |
|
|
Key
string,
required
|
edit
Key for which to search. |
|
|
Scope
string,
optional
|
edit
|
one |
Examples
editNon-Member Function
animals = {
cow: {
noise: "moo",
size: "large"
},
pig: {
noise: "oink"
},
cat: {
noise: "meow",
size: "small"
}
};
// Show all animals
Dump(
label: "All animals",
var: animals
);
// Find "all" animal(s) containing key of 'size'
findAnimalsWithSize = StructFindKey(animals, "size", "all");
// Show results in findAnimalsWithSize
Dump(
label: "Results of StructFindKey(animals, ""size"", ""all"")",
var: findAnimalsWithSize
);
See also
- Structures
- struct.findKey()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)