json_macros
json_macros copied to clipboard
JSON pattern macro
Feature request: a macro which works like json!
, but in a pattern-matching context. Parentheses could be used to insert Rust's regular pattern matching. Example:
if let json_pat!({"isFoo": (Json::Boolean(flag))}) = json_blob {
// matches {"isFoo": true} and {"isFoo": false}, and binds the value of the "isFoo" key to `flag`
if flag { frob(); }
}
For additional convenience, it might also be useful if identifier bindings and the _
and ..
syntaxes were available without parentheses.