macro_rules! array { () => { ... }; ($($tt:tt)+) => { ... }; }
Expand description
Construct a sonic_rs::value::Array
from a JSON array literal.
use sonic_rs::array;
use sonic_rs::json;
use sonic_rs::JsonValueTrait; // tait for `is_null()`
let local = "foo";
let array = array![null, local, true, false, 123, "hello", 1 == 2, array![1, 2, 3], {"key": "value"}];
assert!(array[0].is_null());
assert_eq!(array[1].as_str(), Some("foo"));
assert_eq!(array[array.len() - 2][0].as_u64(), Some(1));
assert_eq!(array[array.len() - 1], json!({"key": "value"}));