Trait bilibili_api_rs::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

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Lodash for Value

source§

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

Implementors§