pub trait Lodash {
    // Required methods
    fn got(&self, path: Vec<&str>) -> &Self;
    fn at(&self, paths: Vec<Vec<&str>>) -> Vec<&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.got(vec!["following", "0", "mid"]), &json!(1472906636));
assert_eq!(v["following"].at(vec![
        vec!["0", "name"],
        vec!["1", "name"]
    ]),
    vec![&json!("ywwuyi"), &json!("Mr.Quin")]);

Required Methods§

source

fn got(&self, path: Vec<&str>) -> &Self

source

fn at(&self, paths: Vec<Vec<&str>>) -> Vec<&Self>

Implementations on Foreign Types§

source§

impl Lodash for Value

source§

fn got(&self, path: Vec<&str>) -> &Self

source§

fn at(&self, paths: Vec<Vec<&str>>) -> Vec<&Self>

Implementors§