ToJsonBehavior

Trait ToJsonBehavior 

Source
pub trait ToJsonBehavior {
    // Required method
    fn to_json(&self) -> String;
}
Expand description

Re-exports from the valu3 library for convenient access to value conversion traits.

§Examples

use quickleaf::prelude::*;

let mut cache = Quickleaf::new(10);

// ToValueBehavior trait is available from the prelude
cache.insert("number", 42);
cache.insert("string", "hello");
cache.insert("boolean", true);

assert_eq!(cache.get("number"), Some(&42.to_value()));
assert_eq!(cache.get("string"), Some(&"hello".to_value()));
assert_eq!(cache.get("boolean"), Some(&true.to_value()));

A trait for converting types to JSON strings.

Required Methods§

Source

fn to_json(&self) -> String

Converts a type into a JSON string.

Implementors§