Skip to main content

JsonExt

Trait JsonExt 

Source
pub trait JsonExt
where 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§

Source

fn to_json(&self) -> Result<Value, String>

Convert to a JSON object

Source

fn to_json_string(&self) -> Result<String, String>

Convert to a JSON-encoded string

Source

fn from_json(t: &Type, value: &Value) -> Result<Self, String>

Convert to JSON object to Self

Source

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".

Implementors§