siderite_cli/report/json.rs
1//! The JSON renderer.
2
3use serde::Serialize;
4
5/// Render `report` as exactly one compact JSON value followed by a
6/// newline, ready to write to stdout. Object keys come out in struct
7/// declaration order, so the output is stable.
8///
9/// Errors:
10/// The serializer's error (not expected for the report types).
11pub fn render<T: Serialize>(report: &T) -> Result<String, serde_json::Error> {
12 let mut out = serde_json::to_string(report)?;
13 out.push('\n');
14 Ok(out)
15}