[][src]Struct json_keypath_iter::Iterator

pub struct Iterator<'a> { /* fields omitted */ }

Iteration strict containing a queue of elements that still need to be yielded along with a style object

Implementations

impl<'a> Iter<'a>[src]

Named Iter internally, but Iterator externally

pub fn new(json: &'a Value) -> Self[src]

Create a new json keypath iterator

Example:

use serde_json::json;
use json_keypath_iter::{Iterator, Element};

let value = json!({"a": [1, 2]});
let iter = Iterator::new(&value);
let items: Vec<_> = iter.collect();

assert_eq!(items[0], Element { path: "[\"a\"][0]".into(), indices: vec![0], value: &json!(1), });
assert_eq!(items[1], Element { path: "[\"a\"][1]".into(), indices: vec![1], value: &json!(2), });

pub fn use_style(self, style: Style<'a>) -> Self[src]

Optionally used to set a custom style for the path in elements

Example:

use serde_json::json;
use json_keypath_iter::{Style, PresetStyle, Iterator, Element};

let style: Style = PresetStyle::CommonJs.into();
let value = json!({"x42": [true, [null, "Hello there."]]});
let iter = Iterator::new(&value).use_style(style);
let items: Vec<_> = iter.collect();

assert_eq!(items[0], Element { path: ".x42[0]".into(), indices: vec![0], value: &json!(true), });
assert_eq!(items[1], Element { path: ".x42[1][0]".into(), indices: vec![1, 0], value: &json!(null), });
assert_eq!(items[2], Element { path: ".x42[1][1]".into(), indices: vec![1, 1], value: &json!("Hello there."), });

Trait Implementations

impl<'a> Debug for Iter<'a>[src]

impl<'a> From<&'a Value> for Iter<'a>[src]

impl<'a> Iterator for Iter<'a>[src]

type Item = Element<'a>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Iter<'a>

impl<'a> Send for Iter<'a>

impl<'a> Sync for Iter<'a>

impl<'a> Unpin for Iter<'a>

impl<'a> UnwindSafe for Iter<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.