Appends one structure to another.
structAppend(destStruct, sourceStruct [, overwriteFlag])
returns boolean
destStruct.append(sourceStruct [, overwriteFlag])
returns struct
Name | Type | Required | Default | Description |
---|---|---|---|---|
destStruct | struct | Yes | Structure to append. | |
sourceStruct | struct | Yes | Structure that contains the data to append to destStruct | |
overwriteFlag | boolean | No | YES | Whether values in sourceStruct should overwrite corresponding values in destStruct or not. |
config = {a:0, b:0};
options= {b:1, c:1};
structAppend(config, options, false);
writeOutput( serializeJSON( config ) );
config = {a:0, b:0};
options= {b:1, c:1};
config.append(options, false);
writeOutput( serializeJSON( config ) );
config = {a:0, b:0};
options= {b:1, c:1};
structAppend(config, options);
writeOutput( serializeJSON( config ) );
Demonstrates how to construct a Request Context (rc) that combines the values of the form and url scopes
rc = {};
structAppend( rc, form );
structAppend( rc, url );
writeOutput( serializeJSON( rc ) );
In older ColdFusion version where this function is not supported yet, you can fall back to a native java method to achieve the same behavior except that it does not have the overwriteFlag
.
config = {a:0, b:0};
options= {b:1, c:1};
config.putAll(options);
writeOutput( serializeJSON( config ) );