User Guide Cancel

StructGet

 

Description

Gets a structure(s) from a specified path.

Returns

An alias to the variable in the pathDesired parameter. If necessary, StructGet creates structures or arrays to make pathDesired a valid variable "path."

Category

Syntax

StructGet(pathDesired)
StructGet(pathDesired)
StructGet(pathDesired)

See also

Structure functionsModifying a ColdFusion XML object in the Developing ColdFusion Applications

History

ColdFusion MX:

  • Changed behavior: this function can be used on XML objects.
  • Changed behavior: if there is no structure or array present in pathDesired, this function creates structures or arrays to make pathDesired a valid variable "path."

Parameters

Parameter

Description

pathDesired

Pathname of  variable  that contains structure or array from which ColdFusion retrieves structure.

Example

<cfscript>
myStruct=StructNew();
myStruct = { x = {y= { z=3.14 } }};
WriteDump(structGet("myStruct.x.y.z") );//Displays 3.14
WriteDump(structGet("myStruct.x.y") );
WriteDump(structGet("myStruct.x") );
WriteDump(myStruct);
</cfscript>
<cfscript> myStruct=StructNew(); myStruct = { x = {y= { z=3.14 } }}; WriteDump(structGet("myStruct.x.y.z") );//Displays 3.14 WriteDump(structGet("myStruct.x.y") ); WriteDump(structGet("myStruct.x") ); WriteDump(myStruct); </cfscript>
<cfscript>
       myStruct=StructNew();
       myStruct = { x = {y= { z=3.14 } }};
       WriteDump(structGet("myStruct.x.y.z") );//Displays 3.14
       WriteDump(structGet("myStruct.x.y") );
       WriteDump(structGet("myStruct.x") );
       WriteDump(myStruct);
</cfscript>

Output

StructGet output
StructGet output

Using empty struct and array of empty struct

<cfscript>
myStruct=StructNew();
myStruct = { x = {y= { z=3.14 } }};
WriteDump(structGet("myStruct.x.y.a") );
WriteDump(myStruct);
WriteDump(structGet("myStruct.x.y") );
WriteDump(structGet("myStruct.x") );
WriteDump(myStruct);
</cfscript>
<cfscript> myStruct=StructNew(); myStruct = { x = {y= { z=3.14 } }}; WriteDump(structGet("myStruct.x.y.a") ); WriteDump(myStruct); WriteDump(structGet("myStruct.x.y") ); WriteDump(structGet("myStruct.x") ); WriteDump(myStruct); </cfscript>
<cfscript>
       myStruct=StructNew();
       myStruct = { x = {y= { z=3.14 } }};
       WriteDump(structGet("myStruct.x.y.a") );
       WriteDump(myStruct);
       WriteDump(structGet("myStruct.x.y") );
       WriteDump(structGet("myStruct.x") );
       WriteDump(myStruct);
</cfscript>

<cfscript>
myStruct=StructNew();
myStruct = { x = {y= { z=3.14 } }};
WriteDump(structGet("myStruct.x.y.a[1]") );
WriteDump(myStruct);
WriteDump(structGet("myStruct.x.y") );
WriteDump(structGet("myStruct.x") );
WriteDump(myStruct);
</cfscript>
<cfscript> myStruct=StructNew(); myStruct = { x = {y= { z=3.14 } }}; WriteDump(structGet("myStruct.x.y.a[1]") ); WriteDump(myStruct); WriteDump(structGet("myStruct.x.y") ); WriteDump(structGet("myStruct.x") ); WriteDump(myStruct); </cfscript>
<cfscript>
       myStruct=StructNew();
       myStruct = { x = {y= { z=3.14 } }};
       WriteDump(structGet("myStruct.x.y.a[1]") );
       WriteDump(myStruct);
       WriteDump(structGet("myStruct.x.y") );
       WriteDump(structGet("myStruct.x") );
       WriteDump(myStruct);
</cfscript>

Get help faster and easier

New user?