View Source Flamel.Map (flamel v1.0.0)

A bunch of helper functions for Maps

Summary

Functions

Converts the top level keys in a map from string to atoms

Converts the top level keys in a map from atoms to strings

Functions

Converts the top level keys in a map from string to atoms

Examples

iex> Flamel.Map.atomize_keys(%{"first_name" => "Thomas", "dob" => "07/01/1981"})
%{first_name: "Thomas", dob: "07/01/1981"}

iex> Flamel.Map.atomize_keys(%{"person" => %{"first_name" => "Thomas", "dob" => "07/01/1981"}})
%{person: %{first_name: "Thomas", dob: "07/01/1981"}}

iex> Flamel.Map.atomize_keys(%{first_name: "Thomas", dob: "07/01/1981"})
%{first_name: "Thomas", dob: "07/01/1981"}

Converts the top level keys in a map from atoms to strings

Examples

iex> Flamel.Map.stringify_keys(%{a: 1, b: 2})
%{"a" => 1, "b" => 2}

iex> Flamel.Map.stringify_keys(%{a: 1, b: 2, c: %{d: 3, e: 4}})
%{"a" => 1, "b" => 2, "c" => %{"d" => 3, "e" => 4}}

iex> Flamel.Map.stringify_keys(%{"a" => 1, "b" => 2})
%{"a" => 1, "b" => 2}