variable_dict_merge

Define a variable resulting of the merge of two other variables.

⚙️ Compatible targets: Linux, Windows

Parameters

NameDocumentation
prefixThe prefix of the variable name.

This parameter is required.
nameThe variable to define, the full name will be prefix.name.

This parameter is required.
first_variableThe first variable, which content will be overridden in the resulting variable if necessary (written in the form prefix.name).

This parameter is required.
second_variableThe second variable, which content will override the first in the resulting variable if necessary (written in the form prefix.name).

This parameter is required.

Outcome conditions

You need to replace ${name} with its actual canonified value.

  • ✅ Ok: variable_dict_merge_${name}_ok
    • ☑️ Already compliant: variable_dict_merge_${name}_kept
    • 🟨 Repaired: variable_dict_merge_${name}_repaired
  • ❌ Error: variable_dict_merge_${name}_error

Example

method: variable_dict_merge
params:
  second_variable: VALUE
  first_variable: VALUE
  prefix: VALUE
  name: VALUE

Documentation

To use the generated variable, you must use the form ${prefix.name[key]} with each name replaced with the parameters of this method.

The resulting variable will be the merge of the two parameters, which means it is built by:

  • Taking the content of the first variable
  • Adding the content of the second variable, and replacing the keys that were already there

It is only a one-level merge, and the value of the first-level key will be completely replaced by the merge.

This method will fail if one of the variables is not defined. See variable_dict_merge_tolerant if you want to allow one of the variables not to be defined.

Usage

If you have a prefix.variable1 variable defined by:

{ "key1": "value1", "key2": "value2", "key3": { "keyx": "valuex" } }

And a prefix.variable2 variable defined by:

{ "key1": "different", "key3": "value3", "key4": "value4" }

And that you use:

variablr_dict_merge("prefix", "variable3, "prefix.variable1", "prefix.variable2")

You will get a prefix.variable3 variable containing:

{
  "key1": "different",
  "key2": "value2",
  "key3": "value3",
  "key4": "value4"
}