structAppend

Appends one structure to another.

structAppend(destStruct, sourceStruct [, overwriteFlag]) → returns boolean

structAppend Argument Reference

destStruct struct
Required

Structure to append.

sourceStruct struct
Required

Structure that contains the data to append to destStruct

overwriteFlag boolean
Default: true

Yes: values in sourceStruct overwrite corresponding values in
destStruct. Default.
Values:
  • true
  • false

Compatibility

ColdFusion:

CF6+ can be used on XML objects as well as structures.

Examples sample code invoking the structAppend function


Append options to config struct (without overwrite flag)

config = {a:0, b:0};
options= {b:1, c:1};
structAppend(config, options, false);
writeOutput( serializeJSON( config ) );

Expected Result: {"A":0,"B":0,"C":1}


Append options to config struct (with overwrite flag)

config = {a:0, b:0};
options= {b:1, c:1};
structAppend(config, options);
writeOutput( serializeJSON( config ) );

Expected Result: {"A":0,"B":1,"C":1}


Fork me on GitHub