Dictionary rename to
This is actually non native complex block which pops value from source dictionary and stores target value into target dictionary with new key name. During transport value is unchanged.
In case source key value does not exists warning is generated. Unfortunately this event can be detected only at runtime.
XML representation of function_dictionaries_rename_key block¶
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="function_dictionaries_rename_key">
<value name="FROM">
<block type="dictionaries_get_index">
<mutation statement="false" at="true"/>
<value name="VALUE">
<block type="variables_get">
<field name="VAR">dictionary</field>
</block>
</value>
<value name="AT">
<block type="text">
<field name="TEXT">foo</field>
</block>
</value>
</block>
</value>
<value name="TO">
<block type="dictionaries_get_index">
<mutation statement="false" at="true"/>
<value name="VALUE">
<block type="variables_get">
<field name="VAR">dictionary</field>
</block>
</value>
<value name="AT">
<block type="text">
<field name="TEXT">bar</field>
</block>
</value>
</block>
</value>
</block>
</xml>
Rename block is used for example for:
- renaming of input data keys in JSON format, when keys are created in source message,
- dictionary created from regular terms, where key names are created dynamically.
In both cases may be needed to adjust input keys to standard names.
In the example the block is used to rename key “ip” to a key “ip_address” in dictionary “item”.
To avoid warnings use this block only in case when you are sure source key exists.
In this case it is solved by containing block int If statement. However in real case there would be better solutions to this.