pub struct ArrayReader<'a, J: JsonReader> { /* private fields */ }
Available on crate feature experimental only.
Expand description

Reader for an arbitrary amount of JSON array items

This struct is used by ValueReader::read_array.

Implementations§

source§

impl<J: JsonReader> ArrayReader<'_, J>

source

pub fn has_next(&mut self) -> Result<bool, ReaderError>

Checks if there is a next item in the JSON array, without consuming it

Returns true if there is a next item, false otherwise. This method can be useful as condition of a while loop when processing a JSON array of unknown size.

§Examples
let json_reader = SimpleJsonReader::new("[1, 2]".as_bytes());
json_reader.read_array(|array_reader| {
    while array_reader.has_next()? {
        let value = array_reader.read_number_as_string()?;
        println!("{value}");
    }
    Ok(())
})?;

Trait Implementations§

source§

impl<'a, J: Debug + JsonReader> Debug for ArrayReader<'a, J>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<J: JsonReader> ValueReader<J> for &mut ArrayReader<'_, J>

source§

fn peek_value(&mut self) -> Result<ValueType, ReaderError>

Peeks at the type of the next JSON value, without consuming it
source§

fn read_null(self) -> Result<(), ReaderError>

Consumes a JSON null value
source§

fn read_bool(self) -> Result<bool, ReaderError>

Consumes and returns a JSON boolean value
source§

fn read_str<T>( self, f: impl FnOnce(&str) -> Result<T, Box<dyn Error>> ) -> Result<T, Box<dyn Error>>

Consumes a JSON string value as borrowed str Read more
source§

fn read_string(self) -> Result<String, ReaderError>

Consumes and returns a JSON string value as owned String Read more
source§

fn read_string_with_reader<T>( self, f: impl FnOnce(StringValueReader<'_>) -> Result<T, Box<dyn Error>> ) -> Result<T, Box<dyn Error>>

Consumes a JSON string using a Read Read more
source§

fn read_number<T: FromStr>(self) -> Result<Result<T, T::Err>, ReaderError>

Consumes and returns a JSON number value Read more
source§

fn read_number_as_string(self) -> Result<String, ReaderError>

Consumes and returns the string representation of a JSON number value Read more
source§

fn read_deserialize<'de, D: Deserialize<'de>>( self ) -> Result<D, DeserializerError>

Available on crate feature serde only.
Deserializes a Serde Deserialize from the next value Read more
source§

fn skip_value(self) -> Result<(), ReaderError>

Skips the next JSON value Read more
source§

fn read_array<T>( self, f: impl FnOnce(&mut ArrayReader<'_, J>) -> Result<T, Box<dyn Error>> ) -> Result<T, Box<dyn Error>>

Consumes a JSON array Read more
source§

fn read_object_borrowed_names( self, f: impl FnMut(MemberReader<'_, J>) -> Result<(), Box<dyn Error>> ) -> Result<(), Box<dyn Error>>

Consumes a JSON object and all of its members, reading names as borrowed str Read more
source§

fn read_object_owned_names( self, f: impl FnMut(String, SingleValueReader<'_, J>) -> Result<(), Box<dyn Error>> ) -> Result<(), Box<dyn Error>>

Consumes a JSON object and all of its members, reading names as owned String Read more
source§

fn read_seeked<T>( self, path: &JsonPath, f: impl FnOnce(SingleValueReader<'_, J>) -> Result<T, Box<dyn Error>> ) -> Result<T, Box<dyn Error>>

Seeks to a value and consumes it Read more
source§

fn read_seeked_multi( self, path: &MultiJsonPath, at_least_one_match: bool, f: impl FnMut(SingleValueReader<'_, J>) -> Result<(), Box<dyn Error>> ) -> Result<(), Box<dyn Error>>

Seeks to multiple values and consumes them Read more
source§

fn read_array_items( self, f: impl FnMut(SingleValueReader<'_, J>) -> Result<(), Box<dyn Error>> ) -> Result<(), Box<dyn Error>>
where Self: Sized,

Consumes a JSON array and all of its items Read more

Auto Trait Implementations§

§

impl<'a, J> Freeze for ArrayReader<'a, J>

§

impl<'a, J> !RefUnwindSafe for ArrayReader<'a, J>

§

impl<'a, J> Send for ArrayReader<'a, J>
where J: Send,

§

impl<'a, J> Sync for ArrayReader<'a, J>
where J: Sync,

§

impl<'a, J> Unpin for ArrayReader<'a, J>

§

impl<'a, J> !UnwindSafe for ArrayReader<'a, J>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.