rename_map_keys
Given a map
of key/value pairs, a subset of keys can be renamed.
Arguments
Name | Description | Type |
---|---|---|
map | A map! | map |
from | Keys in map that will be renamed. | strings |
to | New names of keys in from , order of from and to matters. | strings |
Output value
The inputmap
with from
keys renamed as to
.Example
map = [first: 'sherlock', second: 'john', third: 'james']
rename_map_keys(map, 'third', 'nemesis')
// { "first": "sherlock", "second": "john", "nemesis": "james" }
rename_map_keys(map, ['second','third'], ['hero','nemesis'])
// { "first": "sherlock", "hero": "john", "nemesis": "james" }