smart_city v2.1.5 SmartCity.Helpers View Source
Functions used across SmartCity modules.
Link to this section Summary
Functions
Merges two maps into one, including sub maps. Matching keys from the right map will override their corresponding key in the left map.
Convert a map with string keys to one with atom keys. Will convert keys nested in a sub-map or a map that is part of a list. Ignores atom keys.
Link to this section Functions
Link to this function
deep_merge(left, right) View Source
Merges two maps into one, including sub maps. Matching keys from the right map will override their corresponding key in the left map.
Link to this function
to_atom_keys(map) View Source
Convert a map with string keys to one with atom keys. Will convert keys nested in a sub-map or a map that is part of a list. Ignores atom keys.
Examples
iex> SmartCity.Helpers.to_atom_keys(%{"abc" => 123})
%{abc: 123}
iex> SmartCity.Helpers.to_atom_keys(%{"a" => %{"b" => "c"}})
%{a: %{b: "c"}}
iex> SmartCity.Helpers.to_atom_keys(%{"a" => [%{"b" => "c"}]})
%{a: [%{b: "c"}]}