ExUtils v0.1.7 ExUtils.Map

Elixir Utility methods for the Map module

Summary

Functions

Converts all (string) map keys to atoms

See ExUtils.Map.atomize_keys/1

Functions

atomize_keys(map, opts \\ [])
atomize_keys(map :: Map.t, opts :: Keyword.t) :: Map.t

Converts all (string) map keys to atoms

By default converts all string keys of the map to atoms at the first level. You can recursively convert keys in the base map and all sub-maps by specifiying deep: true in options

You can also call :symbolize_keys/2 instead of :atomize_keys/2

Options

Only accepts one option: deep with default value false

Examples

map = %{"a" => 1, "b" => %{"c" => 3, "d" => 4} }

ExUtils.Map.symbolize_keys(map)
#=> %{a: 1, b: %{"c" => 3, "d" => 4}}

ExUtils.Map.atomize_keys(map, deep: true)
#=> %{a: 1, b: %{c: 3, d: 4}}
symbolize_keys(map)

See ExUtils.Map.atomize_keys/1.

symbolize_keys(map, opts)

See ExUtils.Map.atomize_keys/2.