View Source SmartCity.Helpers (smart_city v6.0.0)
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.
Standardize file type definitions by deferring to the official media type of the file based on a supplied extension.
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 existing atom keys.
Convert a map with atom keys to one with string keys. Will convert keys nested in a sub-map or a map that is part of a list. Ignores existing string keys.
Link to this section Types
Link to this section Functions
Merges two maps into one, including sub maps. Matching keys from the right map will override their corresponding key in the left map.
Standardize file type definitions by deferring to the official media type of the file based on a supplied extension.
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 existing atom keys.
examples
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"}]}
Convert a map with atom keys to one with string keys. Will convert keys nested in a sub-map or a map that is part of a list. Ignores existing string keys.
examples
Examples
iex> SmartCity.Helpers.to_string_keys(%{abc: 123})
%{"abc" => 123}
iex> SmartCity.Helpers.to_string_keys(%{a: %{b: "c"}})
%{"a" => %{"b" => "c"}}
iex> SmartCity.Helpers.to_string_keys(%{a: [%{b: "c"}]})
%{"a" => [%{"b" => "c"}]}