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

Type-preserving canonical JSON bytes for stable application identity.

PTC-Lisp distinguishes integer and float runtime values, while ordinary JSON
canonicalization does not. TJCS first projects every node to a tagged tree
and then emits deterministic UTF-8 JSON:

- scalars become `["null"]`, `["boolean", value]`,
  `["string", value]`, `["integer", decimal]`, or
  `["float64", ieee754_hex]`;
- arrays become `["array", [...]]`; and
- objects become `["object", [[key, tagged_value], ...]]`, sorted by key
  UTF-8 bytes.

Every input passes through `PtcRunner.Kernel.StrictJSON`, so duplicate keys
from decoded bytes, invalid Unicode, non-finite floats, excessive depth, and
excessive node counts are rejected before identity traversal.

# `error`

```elixir
@type error() :: PtcRunner.Kernel.StrictJSON.error() | :invalid_json
```

# `encode`

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

Admits and encodes one JSON-shaped value as TJCS bytes.

---

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