to_string

Function to_string 

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

Serialize a value to a JSON string.

ยงExample

use facet::Facet;
use facet_json::to_string;

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

let person = Person { name: "Alice".into(), age: 30 };
let json = to_string(&person).unwrap();
assert_eq!(json, r#"{"name":"Alice","age":30}"#);