Function deser_hjson::from_slice

source ·
pub fn from_slice<T>(bytes: &[u8]) -> Result<T>where
    T: DeserializeOwned,
Expand description

Deserialize an instance of type T from bytes of Hjson text

Example

use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct User {
    fingerprint: String,
    location: String,
}

// The type of `j` is `&[u8]`
let j = b"
    fingerprint: 0xF9BA143B95FF6D82
    location: Menlo Park, CA
";

let u: User = deser_hjson::from_slice(j).unwrap();
println!("{:#?}", u);