Lodash

Trait Lodash 

Source
pub trait Lodash {
    // Required method
    fn at(&self, paths: Value) -> Self;
}
Expand description

Lodash-like get helper, implemented for serde_json

use bilibili_api_rs::Lodash;
let v = json!({
    "following": [ {
        "mid": 1472906636,
        "name": "ywwuyi",
    }, {
        "mid": 15810,
        "name": "Mr.Quin",
    }],
});
assert_eq!(v.at(json!(["following", 0, "mid"])), json!(1472906636));
assert_eq!(v["following"].at(json!([
        [0, "name"],
        [1, "name"],
    ])),
    json!(["ywwuyi", "Mr.Quin"]));

Required Methods§

Source

fn at(&self, paths: Value) -> Self

Input a matrix, output a vector; input a vector, output single one value

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Lodash for Value

Source§

fn at(&self, paths: Value) -> Self

Implementors§