# `Juggernaut.View.JSON`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/view/json.ex#L1)

JSON encoding for the machine formats (design notes §5.2).

Documents are built from `Jason.OrderedObject`s so keys keep the documented order.
Strings that reach a document (diffs, source excerpts, test names, reasons) may hold
bytes that are not UTF-8; `Jason` refuses those (deps:jason), so every binary is
scrubbed first, each invalid sequence replaced with U+FFFD.

# `encode!`

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

Encodes `term` compactly after `scrub/1`. Never pretty: NDJSON lines are one line.

# `object`

```elixir
@spec object([{String.t(), term()}]) :: Jason.OrderedObject.t()
```

An ordered JSON object from `{key, value}` pairs.

# `scrub`

```elixir
@spec scrub(term()) :: term()
```

Replaces invalid UTF-8 in every binary of `term` (keys too) with U+FFFD.

---

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