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Β§
- Json
Envelope - Stable top-level envelope for complete machine-readable command output.
- Json
Error - A terminal JSON command failure that preserves command-specific output data.
- Json
Message - Structured diagnostic entry for JSON output.
EnumsΒ§
- Json
Message Level - 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
--jsonmode, 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
--jsonmode, 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
--jsonmode, one item per line otherwise. - print_
scalar - Prints a scalar value: JSON envelope in
--jsonmode, plain text otherwise. - print_
tokens - Prints ABI-decoded tokens: JSON envelope wrapping a value array in
--jsonmode, one formatted token per line otherwise.