# `PtcRunner.Kernel.DeterministicJSON`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/kernel/deterministic_json.ex#L1)

Internal deterministic encoder for frozen Kernel metadata and hashes.

Ordinary maps require binary UTF-8 keys or valid public symbol-reference
wrappers and are recursively sorted by their normalized key bytes.
`{:object, pairs}` accepts the same key types, preserves an explicit key
order for versioned projections, and rejects duplicate normalized keys
before a map could erase them. Symbol-reference values are likewise encoded
as their display strings. Arrays retain their input order and output contains
no insignificant whitespace.

# `json_key`

```elixir
@type json_key() :: binary() | %PtcRunner.Lisp.Format.SymbolRef{name: binary()}
```

# `ordered_object`

```elixir
@type ordered_object() :: {:object, [{json_key(), term()}]}
```

# `encode`

```elixir
@spec encode(term() | ordered_object()) ::
  {:ok, binary()} | {:error, :invalid_json | :duplicate_key}
```

---

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