PtcRunner.Kernel.StrictJSON (PtcRunner v0.14.0)

Copy Markdown View Source

Bounded, duplicate-rejecting JSON admission for authority boundaries.

Objects are decoded as ordered key-value pairs first, then recursively converted to ordinary maps only when every object key is unique. Decoding and trusted in-memory admission share the same depth, node, UTF-8, finite number, timeout, and heap limits.

Summary

Functions

Admits a trusted in-memory JSON value under the same limits as decode/2.

Decodes one JSON value under the shared structural admission limits.

Decodes one JSON value and retains the bounded parent location of a duplicate.

Types

error()

@type error() ::
  :invalid_json
  | :duplicate_json_key
  | {:duplicate_json_key, [binary() | non_neg_integer()]}
  | :json_depth_exceeded
  | :json_node_limit_exceeded

located_error()

@type located_error() ::
  error()
  | {:invalid_json,
     [binary() | non_neg_integer() | {:map_key, non_neg_integer()}],
     :improper_list
     | :invalid_object_key
     | :invalid_utf8
     | :non_finite_float
     | :unsupported_value}

Functions

admit(value, opts \\ [])

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

Admits a trusted in-memory JSON value under the same limits as decode/2.

Structs, non-binary keys, invalid UTF-8, improper lists, and non-finite floats are rejected.

decode(source, opts \\ [])

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

Decodes one JSON value under the shared structural admission limits.

Options may only narrow :max_depth and :max_nodes.

decode_with_locations(source, opts \\ [])

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

Decodes one JSON value and retains the bounded parent location of a duplicate.

Location segments are internal evidence. Callers must authorize them against their own closed schema before projecting a public path.