Macro json::extract
[−]
[src]
macro_rules! extract { ( let decoder = $dec:ident; let buffer = $buf:expr; $($name:ident: $modus:ident. $typ:ty = $key:expr => $action:expr),+ ) => { ... }; ( let buffer = $buf:expr; $($name:ident: $modus:ident. $typ:ty = $key:expr => $action:expr),+ ) => { ... }; ( let decoder = $dec:ident; $($name:ident: $modus:ident. $typ:ty = $key:expr => $action:expr),+ ) => { ... }; ( $($name:ident: $modus:ident. $typ:ty = $key:expr => $action:expr),+ ) => { ... }; }
Macro to support extraction of subsets of JSON object fields.
Optionally extract!
accepts a Utf8Buffer
to use when
decoding object keys. Also decoder
can be omitted in which
case the macro expands to a lambda function expecting the
decoder as argument (this form is useful for nested object!
invocations).
Example:
let p = extract! {
let decoder = d;
x: req. u32 = "x" => Decoder::from_json,
y: req. u32 = "y" => Decoder::from_json
}
println!("x={}, y={}", p.x, p.y)