pub fn stringify_compact<T: Serialize>(
val: &T,
line_width: usize,
indent: usize,
) -> Result<String, SerializeError<Infallible>>Expand description
Serialize a value into a smart-pretty-printed heap-allocated [String].
Each object or array whose compact JSON length is ≤ line_width bytes is kept
on a single line; larger containers are expanded to multi-line with indent-space
indentation applied recursively.
§Example
let json = nanojson::stringify_compact(&[1i64, 2, 3], 40, 2).unwrap();
assert_eq!(json, "[1, 2, 3]");