rename_map_keys

Given a map of key/value pairs, a subset of keys can be renamed.

github

Arguments

NameDescriptionType
mapA map!map
fromKeys in map that will be renamed.strings
toNew names of keys in from, order of from and to matters.strings

Output value

The input map 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" }