PtcRunner.Kernel.TypedCanonicalJSON (PtcRunner v0.14.0)

Copy Markdown View Source

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.

Summary

Functions

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

Types

error()

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

Functions

encode(value, opts \\ [])

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

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