Skip to main content

jvalue

Macro jvalue 

Source
macro_rules! jvalue {
    (null) => { ... };
    (true) => { ... };
    (false) => { ... };
    ([ $($elem:tt),* $(,)? ]) => { ... };
    ({ $($key:tt : $val:tt),* $(,)? }) => { ... };
    ($other:expr) => { ... };
}
Expand description

Macro for constructing JValue literals, similar to serde_json::json!

Usage: jvalue!(null) → JValue::Null jvalue!(true) → JValue::Bool(true) jvalue!(false) → JValue::Bool(false) jvalue!(42) → JValue::Number(42.0) jvalue!(3.14) → JValue::Number(3.14) jvalue!(“hello”) → JValue::String(Rc::from(“hello”)) jvalue!([1, 2, 3]) → JValue::Array(Rc::new(vec![…])) jvalue!({“k”: v, …}) → JValue::Object(Rc::new(IndexMap from pairs)) jvalue!(expr) → JValue::from(expr)