Skip to main content

Module json

Module json 

Source
Expand description

Shared JSON output primitives for Foundry CLIs.

Structs§

JsonEnvelope
Stable top-level envelope for complete machine-readable command output.
JsonMessage
Structured diagnostic entry for JSON output.
StreamRecord
One NDJSON record on a long-running command’s stream. The kind-specific payload is flattened into the same object alongside the spec fields (schema_id, command_id, kind, ts).

Enums§

JsonMessageLevel
Severity level for a structured JSON diagnostic.

Constants§

JSON_SCHEMA_VERSION
The current version of Foundry’s top-level JSON output envelope.

Functions§

print_json
Prints a value as one compact JSON line on stdout and flushes.
print_json_object
Prints a serializable object: envelope-wrapped in --json mode, pretty-printed otherwise.
print_json_success
Prints a successful JSON envelope to stdout.
print_json_success_with_warnings
Prints a successful JSON envelope with warnings to stdout.
print_json_value_or_scalar
Prints command output that may already be JSON: parsed and envelope-wrapped in --json mode, plain text otherwise. If the output is not valid JSON, it is wrapped as a scalar string.
print_list
Prints a list of serializable items: JSON envelope wrapping an array in --json mode, one item per line otherwise.
print_scalar
Prints a scalar value: JSON envelope in --json mode, plain text otherwise.
print_stream_record
Emits a single NDJSON record on stdout for a streaming command.
print_tokens
Prints ABI-decoded tokens: JSON envelope wrapping a value array in --json mode, one formatted token per line otherwise.