ExUtils v0.1.6 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 and all sub-maps to atoms. Conversion to atoms can be limited to the base map by specifiying recursive: false in options

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

Options

Only accepts one option: recursive with default value true

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, recursive: false)
#=> %{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.