key_tools v0.1.0 KeyTools

Provides common functions for coercing a Map or List.

Summary

Functions

Deeply converts all string keys within the given Map or List to atoms

Deeply converts all keys within the given Map or List to strings

Functions

atomize_keys(map)

Deeply converts all string keys within the given Map or List to atoms.

Examples

iex(1)> KeyTools.atomize_keys %{“data” => ["Hello", "World!"]} %{data: ["Hello", "World!"]}

iex(2)> KeyTools.atomize_keys [%{"nested_data" => %{"deep" => :stuff}}] [%{nested_data: %{deep: :stuff}}]

stringify_keys(map)
underscore_keys(map)

Deeply converts all keys within the given Map or List to strings.

Examples

iex(1)> stringify_keys %{atom_key: :atom_value} %{“atom_key” => :atom_value}

iex(2)> stringify_keys [%{atom_key: %{42 => [%{another_key: 23}]}}] [%{"atom_key" => %{"42" => [%{"another_key" => 23}]}}]