pub struct Tree {
pub entries: Vec<Entry>,
pub keys: Vec<Key>,
}
Fields§
§entries: Vec<Entry>
§keys: Vec<Key>
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn value_at(&self, path: &[PathType<'_>]) -> Vec<&Entry>
pub fn value_at(&self, path: &[PathType<'_>]) -> Vec<&Entry>
Get values at a path. Wildcard and recursive wildcard available.
Example
let text = "{ \"a\": { \"b\": ["c"] } }";
match parse_json(&text) {
Ok(tree) => {
let keys = tree.values_at(&[
PathType::Object("a"),
PathType::Object("b"),
PathType::Array(0),
]);
},
Err(e) => println!("{:?}", e),
};
Sourcepub fn keys_at(&self, path: &[PathType<'_>]) -> Vec<&Key>
pub fn keys_at(&self, path: &[PathType<'_>]) -> Vec<&Key>
Get keys at a path. Wildcard and recursive wildcard available.
Example
let text = "{ \"a\": { \"b\": ["c"] } }";
match parse_json(&text) {
Ok(tree) => {
let keys = tree.keys_at(&[
PathType::Object("a"),
PathType::Object("b"),
PathType::Array(0),
]);
},
Err(e) => println!("{:?}", e),
};
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tree
impl RefUnwindSafe for Tree
impl Send for Tree
impl Sync for Tree
impl Unpin for Tree
impl UnwindSafe for Tree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more