macro_rules! rumtk_deserialize {
( $string:expr ) => { ... };
}Expand description
Deserialization macro which will take a JSON string representation and return an instance of the specified type.
Pass the json string to deserialize. You will need to specify the expected type that will be generated.
ยงExample
pub use crate::rumtk_core::json::serialization::{Serialize, Deserialize};
use crate::rumtk_core::strings::RUMString;
use crate::rumtk_core::{rumtk_serialize, rumtk_deserialize};
#[derive(Serialize, Deserialize, PartialEq)]
struct MyStruct {
hello: RUMString
}
let hw = MyStruct{hello: RUMString::from("World")};
let hw_str = rumtk_serialize!(&hw, true).unwrap();
let new_hw: MyStruct = rumtk_deserialize!(&hw_str).unwrap();
assert!(
new_hw == hw,
"Deserialized JSON does not match the expected value!"
);