to_string_pretty

Function to_string_pretty 

Source
pub fn to_string_pretty<'facet, T>(
    value: &T,
) -> Result<String, SerializeError<JsonSerializeError>>
where T: Facet<'facet> + ?Sized,
Expand description

Serialize a value to a pretty-printed JSON string.

ยงExample

use facet::Facet;
use facet_json::to_string_pretty;

#[derive(Facet)]
struct Person { name: String, age: u32 }

let person = Person { name: "Alice".into(), age: 30 };
let json = to_string_pretty(&person).unwrap();
assert!(json.contains('\n'));