json
json copied to clipboard
get_concurrent values
/// Similar to `get` method but fast to get deep json Value
/// ```
/// # use serde_json::json;
///
/// let object = json!({ "A": { "B": { "C": "foo" } } }); // true
///
/// assert_eq!(*array.get_concurrent("A.B.C").unwrap(), json!("foo")); // true
/// assert_eq!(*array.get_concurrent("A.B.C.D").unwrap(), json!("foo")); // true also
/// ```
pub fn get_concurrent(&self, list: &str) -> Option<Value> {
let rest: Value = Value::default();
for item in list.split(".").into_iter() {
let rest = match self.0.get(item) {
Some(m) => Some(m),
None => Some(&self.0),
};
}
Some(rest)
}
I suspect this won't be merged as-is. It is a rather opinionated feature for such a fundamental crate.
Also, it's not ready needed: object["A"]["B"]["C"] works.
I made some changes on it so it will fit my needs. Thanks overall
On Tue, May 23, 2023, 19:28 kangalio @.***> wrote:
I suspect this won't be merged as-is. It is a rather opinionated feature for such a fundamental crate.
Also, it's not ready needed: object["A"]["B"]["C"] works.
— Reply to this email directly, view it on GitHub https://github.com/serde-rs/json/pull/930#issuecomment-1559944100, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKPIGZMNNOIJH3MFGYTD53XHT6WJANCNFSM6AAAAAAQJ4LUFM . You are receiving this because you authored the thread.Message ID: @.***>