Snakepit.Utils (snakepit v0.1.2)

Utility functions for Snakepit.

This module contains common helper functions used across the Snakepit codebase to avoid code duplication and provide consistent behavior.

Summary

Functions

Recursively converts atom keys to string keys in maps and lists.

Functions

stringify_keys(map)

@spec stringify_keys(any()) :: any()

Recursively converts atom keys to string keys in maps and lists.

This is useful when preparing data for JSON serialization where all keys need to be strings.

Examples

iex> Snakepit.Utils.stringify_keys(%{foo: "bar", baz: %{nested: "value"}})
%{"foo" => "bar", "baz" => %{"nested" => "value"}}

iex> Snakepit.Utils.stringify_keys([%{key: "value"}, %{another: "test"}])
[%{"key" => "value"}, %{"another" => "test"}]

iex> Snakepit.Utils.stringify_keys("already_string")
"already_string"