Juggernaut.View.JSON (Juggernaut v0.4.0)

Copy Markdown View Source

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

Documents are built from Jason.OrderedObjects 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.

Summary

Functions

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

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

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

Functions

encode!(term)

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

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

object(pairs)

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

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

scrub(binary)

@spec scrub(term()) :: term()

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