[−][src]Function polyglot::de::from_str
pub fn from_str<T>(s: &str, format: Format) -> Result<T> where
T: DeserializeOwned,
Deserialize a struct from a string in the specified format.
Obviously, only formats enabled with feature flags will be supported.
Example
use polyglot::{de, Format}; use serde::Deserialize; #[derive(Debug, Deserialize)] struct Person { pub age: i32 } let p: Person = de::from_str("{\"age\": 42}", Format::JSON).unwrap(); assert_eq!(p.age, 42);