Trait JSON

Source
pub trait JSON: Serialize {
    // Provided methods
    fn string(&self) -> Result<String> { ... }
    fn stringify(&self, indent: usize) -> Result<String> { ... }
}

Provided Methods§

Source

fn string(&self) -> Result<String>

Return a concise JSON string

Source

fn stringify(&self, indent: usize) -> Result<String>

Stringify a native-json object

indent

  • 0 : output concise JSON string
  • N : pretty output with N spaces indentation

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.

Implementors§

Source§

impl<T> JSON for T
where T: Serialize,