pub fn from_value<T>(value: Value) -> Result<T, DeserializeError>where
T: DeserializeOwned,
Expand description
Deserializes the JSON value
into an instance of type T
.
ยงExample
use serde::Deserialize;
use json_syntax::{json, Value};
#[derive(Deserialize, Debug)]
struct User {
fingerprint: String,
location: String,
}
let j: Value = json!({
"fingerprint": "0xF9BA143B95FF6D82",
"location": "Menlo Park, CA"
});
let u: User = json_syntax::from_value(j).unwrap();
println!("{:#?}", u);