# `PhoenixKit.Modules.Emails.Utils.Json`
[🔗](https://github.com/BeamLabEU/phoenix_kit_emails/blob/0.4.2/lib/phoenix_kit/modules/emails/utils/json.ex#L1)

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

This module's own code uses the built-in `JSON` module directly for plain
encode/decode — this exists only for the handful of call sites (JSON
offered to an admin as a downloadable export) that need indented output.

Mirrors `PhoenixKit.Utils.Json` from core (phoenix_kit) — duplicated here
because that helper isn't in the currently-published core version this
project depends on. Safe to delete and delegate to core's version once a
release with it is available.

# `encode_pretty!`

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

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

`term` is encoded via `JSON.encode!/1` and decoded back first, so structs
(e.g. Ecto schemas with `@derive {JSON.Encoder, ...}`) go through the
`JSON.Encoder` protocol correctly — the recursive pretty-printer below
only ever walks plain maps/lists/primitives, never a raw struct (which
doesn't implement `Enumerable`).

## Examples

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
