ex_ex v0.1.0 ExEx.Map
Functions that extend the capabilities of the built-in Map module.
Link to this section Summary
Functions
Converts the map’s keys from strings to atoms
Removes keys from the map for which the respective value is nil
Sanitizes structs more thoroughly than Map.from_struct/1
Converts the map’s keys from atoms to strings
Link to this section Functions
Converts the map’s keys from strings to atoms.
If the keys are already atoms, then they are preserved.
Examples
iex> ExEx.Map.atomize_keys(%{"foo": "bar", "baz": 123})
%{foo: "bar", baz: 123}
Removes keys from the map for which the respective value is nil.
Examples
iex> ExEx.Map.drop_nil_values(%{“foo”: nil, “bar”: 123}) %{bar: 123}
Sanitizes structs more thoroughly than Map.from_struct/1.
This is intended for use cases when the struct will be serialized and cannot
contain Ecto syntax such as #Ecto.Schema.Metadata<:built, "media_metadata">.
Converts the map’s keys from atoms to strings.
If the keys are already strings, then they are preserved.
Examples
iex> ExEx.Map.stringify_keys(%{foo: "bar", baz: 123})
%{"foo" => "bar", "baz" => 123}