pub trait JsonExtwhere
Self: Sized,{
// Required methods
fn to_json(&self) -> Result<Value, String>;
fn to_json_string(&self) -> Result<String, String>;
fn from_json(t: &Type, value: &Value) -> Result<Self, String>;
fn from_json_str(t: &Type, value: &str) -> Result<Self, String>;
}
Available on crate feature
internal-json
only.Expand description
Extension trait, adding JSON serialization methods
Required Methods§
Sourcefn to_json_string(&self) -> Result<String, String>
fn to_json_string(&self) -> Result<String, String>
Convert to a JSON-encoded string
Sourcefn from_json_str(t: &Type, value: &str) -> Result<Self, String>
fn from_json_str(t: &Type, value: &str) -> Result<Self, String>
Convert to JSON encoded string to Self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.