CodexEx.MapHelpers (codex_ex v0.1.0)

Copy Markdown View Source

Shallow key normalisation for maps entering from external sources.

Summary

Functions

Recursively converts atom keys to string keys across nested maps/lists.

Converts atom keys to string keys (one level deep).

Functions

deep_stringify_keys(struct)

@spec deep_stringify_keys(term()) :: term()

Recursively converts atom keys to string keys across nested maps/lists.

stringify_keys(struct)

@spec stringify_keys(term()) :: term()

Converts atom keys to string keys (one level deep).

iex> CodexEx.MapHelpers.stringify_keys(%{"bar" => 2, foo: 1})
%{"foo" => 1, "bar" => 2}