Skip to main content

emit_json

Function emit_json 

Source
pub fn emit_json<T: Serialize>(value: &T) -> Result<(), AppError>
Expand description

Serializes value as pretty-printed JSON and writes it to stdout with a trailing newline.

Flushes stdout after writing. A BrokenPipe error is silenced so that piping to consumers that close early (e.g. head) does not surface an error.

ยงErrors

Returns Err when serialization fails or when a non-BrokenPipe I/O error occurs.