macro_rules! plist_dict {
() => { ... };
({$($tt:tt)+}) => { ... };
($($tt:tt)+) => { ... };
}Expand description
Constructs a plist::Dictionary from a JSON-like literal.
let value = plist_dict! {
"code": 200,
"success": true,
"payload": {
"features": [
"serde",
]
}
};Variables or expressions can be interpolated into the literal. Any type
interpolated into an array element or object value must implement the
Into<Value> trait, while any type interpolated into a object key must
implement Into<String>.
let code = 200;
let features = vec!["serde", "plist"];
let value = plist_dict! {
"code": code,
"success": code == 200,
"payload": {
features[0]: features[1]
}
};Trailing commas are allowed inside both arrays and objects.
let value = plist_dict! {
"notice": 0,
"the": 1,
"trailing": 2,
"comma -->": 3,
};