pub fn print_json_with_indent<T: Serialize>(
value: T,
indent: usize,
) -> Result<(), Error>
Expand description
Pretty-print a serializable value as JSON with a custom indentation. Will returns an Error if the value cannot be serialized or if the output is not valid UTF-8.
use jsonutils::print::print_json_with_indent;
use serde_json::json;
let json = json!({
"name": "Alice",
"age": 30,
"is_student": false
});
print_json_with_indent(json, 2).unwrap();