macro_rules! jmap {
{$($k:tt: $v:tt),*} => { ... };
() => { ... };
}
Expand description
Helper macro to build a Map<String, Value>
This is useful when using any of the API methods that require a Map<String, Value>
,
as serde_json
doesn’t have a way to build these.
§Example:
// Manually
let mut kwargs = Map::<String, Value>::new();
kwargs.insert("domain".into(), json!([["name", "ilike", "admin"]]));
kwargs.insert("fields".into(), json!(["id", "login"]));
let request = client.execute_kw(
"res.users",
"search_read",
jvec![],
kwargs,
).send()?;
// With jmap!{}:
let request = client.execute_kw(
"res.users",
"search_read",
jvec![],
jmap!{
"domain": [["name", "ilike", "admin"]],
"fields": ["id", "login"]
}
).send()?;