macro_rules! object {
{} => { ... };
{
$( $key: ident $(: $value: expr)? ),* $(,)?
} => { ... };
(@entry $hm: expr,
$key: ident
) => { ... };
(@entry $hm: expr,
$key: ident : $value: expr
) => { ... };
}
Expand description
Create a json-like ‘object’: A map of string keys to json values
unreact::Object
is a type alias for serde_json::Map<String, serde_json::Value>
Similar to serde_json::json!
macro, but must be an object
§Examples
let my_key = "Hello!";
object! {
foo: 123,
bar: vec![4, 5, 6],
// Use variable with same name as key
my_key,
// Nested objects must also use `object!` macro
nested: object! {
key: "value"
}
};
The above code is equivalent to this json:
{
"foo": 123,
"bar": [4, 5, 6],
"my_key": "Hello!",
"nested": {
"key": "value"
}
}