Inserts a key-value pair into a structure.
structInsert(structure, key, value [, allowoverwrite])
returns boolean
Name | Type | Required | Default | Description |
---|---|---|---|---|
structure | struct | Yes | Structure to contain the new key-value pair. | |
key | string | Yes | Key that contains the inserted value. | |
value | any | Yes | Value to add. | |
allowoverwrite | boolean | No | NO | Whether to allow overwriting a key. Default: False. |
Inserts a new key/value into the structure
map = {
"hair" : "brown",
"eyes" : "green"
};
structInsert(map, "lips", "red");
writeOutput(structKeyList(map));
Throws exception when you try to add a duplicate key, when allowoverwrite parameter is false.
map = {
"hair" : "brown",
"eyes" : "green"
};
try {structInsert(map, "hair", "red", false);}
catch(any ex) {writeOutput("error!");}