Skip to main content

from_str

Function from_str 

Source
pub fn from_str<T: DeserializeOwned>(input: &str) -> Result<T>
Expand description

Parse a TJSON string and deserialize it into T using serde.

#[derive(serde::Deserialize, PartialEq, Debug)]
struct Person { name: String, city: String }

let p: Person = tjson::from_str("  name: Alice  city: London").unwrap();
assert_eq!(p, Person { name: "Alice".into(), city: "London".into() });