PhoenixKit.Utils.Json (phoenix_kit v1.7.199)

Copy Markdown View Source

Thin helper around Elixir's built-in JSON module (1.18+) for the one thing it doesn't provide: pretty-printing.

PhoenixKit's own code uses the built-in JSON module directly for plain encode/decode — this module exists only for the handful of call sites (JSON shown back to an admin in a textarea, or in a debug view) that need indented output.

Summary

Functions

Encodes term as indented, human-readable JSON (2-space indent).

Functions

encode_pretty!(term)

@spec encode_pretty!(term()) :: String.t()

Encodes term as indented, human-readable JSON (2-space indent).

Examples

iex> PhoenixKit.Utils.Json.encode_pretty!(%{"a" => 1})
~s({\n  "a": 1\n})