valq

valq
provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax.
Look & Feel:
use Value;
use query_value;
let j: Value = ...;
let deep_val: = query_value!;
For now, there is only single macro exported: query_value
.
query_value
macro
A macro for querying inner value of structured data.
Basic Usage
// get field `foo` from JSON object `obj`
let foo = query_value!;
// get nested field `bar` inside object `foo` in JSON object `obj`
let bar = query_value!;
// get head of JSON array 'arr'
let head = query_value!;
// get head of nested JSON array `arr` in JSON object `obj`
let head = query_value!;
// more complex example!
let abyss = query_value!;
Converting to Specified Type
// try to convert extracted value to `u64` by `as_u64()` method on that value.
// results in `None` in case of type mismatch
let foo_u64: = query_value!
// in case of mutable reference extraction (see below), `as_xxx_mut()` method will be used.
let arr_vec: = query_value!
Extracting Mutable Reference to Inner Value
use
let mut obj = json!;
assert_eq!;
assert_eq!;