Skip to main content

to_string

Function to_string 

Source
pub fn to_string<T: Serialize>(value: &T) -> Result<String>
Expand description

Serialize value to a TJSON string using default options.

#[derive(serde::Serialize)]
struct Person { name: &'static str }

let s = tjson::to_string(&Person { name: "Alice" }).unwrap();
assert_eq!(s, "  name: Alice");