Skip to main content

Module json

Module json 

Source
Expand description

Shared JSON output primitives for Foundry CLIs.

Re-exportsΒ§

use alloy_dyn_abi::DynSolValue; πŸ”’
use eyre::Result; πŸ”’
use foundry_common::fmt::format_tokens; πŸ”’
use foundry_common::fmt::serialize_value_as_json; πŸ”’
use foundry_common::sh_println; πŸ”’
use foundry_common::shell; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use serde_json::Value; πŸ”’
use serde_json::to_string; πŸ”’

StructsΒ§

JsonEnvelope
Stable top-level envelope for complete machine-readable command output.
JsonError
A terminal JSON command failure that preserves command-specific output data.
JsonMessage
Structured diagnostic entry for JSON output.

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_tokens
Prints ABI-decoded tokens: JSON envelope wrapping a value array in --json mode, one formatted token per line otherwise.