Macro json_with_comments::jsonc
source · macro_rules! jsonc { ($($json:tt)*) => { ... }; }
Expand description
Construct a crate::Value
from rust value.
§Examples
use json_with_comments::{jsonc, Value, value::number::Number};
assert_eq!(jsonc!({
"object": {"key": "value"},
"array": [null, 1, 1 + 1],
"bool": true,
"null": null,
"string": "String".to_string(),
"number": 1,
}),
Value::Object(([
("object".to_string(), Value::Object(vec![("key".into(), "value".into())].into_iter().collect())),
("array".to_string(), Value::Array(vec![().into(), 1.into(), 2.into()])),
("bool".to_string(), Value::Bool(true)),
("null".to_string(), Value::Null),
("string".to_string(), Value::String("String".to_string())),
("number".to_string(), Value::Number(Number::Integer(1))),
].into_iter().collect())),
);