pub fn to_string_with_options<'facet, T: Facet<'facet> + ?Sized>(
value: &T,
options: &SerializeOptions,
) -> StringExpand description
Serializes a value implementing Facet to a JSON string with custom options.
ยงExample
use facet::Facet;
use facet_json::{to_string_with_options, SerializeOptions};
#[derive(Facet)]
struct Person {
name: String,
age: u32,
}
let person = Person { name: "Alice".to_string(), age: 30 };
// Compact output
let json = to_string_with_options(&person, &SerializeOptions::default());
assert_eq!(json, r#"{"name":"Alice","age":30}"#);
// Pretty output with tabs
let json = to_string_with_options(&person, &SerializeOptions::default().indent("\t"));