macro_rules! jsonc_generics {
    ([$($array:tt)*]) => { ... };
    ({$($object:tt)*}) => { ... };
    (null) => { ... };
    ($instance:expr) => { ... };
}
Expand description

Construct a crate::value::JsoncValue from rust value. If use without generics, see jsonc! also.

§Examples

use json_with_comments::{jsonc_generics, value::{JsoncValue, number::Number}};

assert_eq!(jsonc_generics!({
        "object": {"key": "value"},
        "array": [null, 1, 1 + 1],
        "bool": true,
        "null": null,
        "string": "String".to_string(),
        "number": 1,
    }),
    JsoncValue::<u8, f32>::Object(([
        ("object".to_string(), JsoncValue::Object(vec![("key".into(), "value".into())].into_iter().collect())),
        ("array".to_string(), JsoncValue::Array(vec![().into(), 1.into(), 2.into()])),
        ("bool".to_string(), JsoncValue::Bool(true)),
        ("null".to_string(), JsoncValue::Null),
        ("string".to_string(), JsoncValue::String("String".to_string())),
        ("number".to_string(), JsoncValue::Number(Number::Integer(1))),
    ].into_iter().collect())),
);