pub trait JsonUtil:
Sized
+ Serialize
+ DeserializeOwned{
type Err: Debug;
// Provided methods
fn from_json<T>(json: T) -> Result<Self, Self::Err>
where T: AsRef<[u8]> { ... }
fn as_json(&self) -> String { ... }
fn try_as_json(&self) -> Result<String, Self::Err> { ... }
fn as_pretty_json(&self) -> String { ... }
fn try_as_pretty_json(&self) -> Result<String, Self::Err> { ... }
}Expand description
JSON util
Required Associated Types§
Provided Methods§
Sourcefn as_json(&self) -> String
fn as_json(&self) -> String
Serialize as JSON string
This method could panic! Use try_as_json for error propagation.
Sourcefn try_as_json(&self) -> Result<String, Self::Err>
fn try_as_json(&self) -> Result<String, Self::Err>
Serialize as JSON string
Sourcefn as_pretty_json(&self) -> String
fn as_pretty_json(&self) -> String
Serialize as pretty JSON string
This method could panic! Use try_as_pretty_json for error propagation.
Sourcefn try_as_pretty_json(&self) -> Result<String, Self::Err>
fn try_as_pretty_json(&self) -> Result<String, Self::Err>
Serialize as pretty JSON string
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.