Skip to main content

JsonParser

Struct JsonParser 

Source
pub struct JsonParser<'a> { /* private fields */ }
Expand description

High-performance JSON parser

Implementations§

Source§

impl<'a> JsonParser<'a>

Source

pub fn new(input: &'a str) -> Self

Create a new parser from a string slice

Source

pub fn from_bytes(input: &'a [u8]) -> Self

Create a new parser from bytes

Source

pub fn position(&self) -> usize

Get current position

Source

pub fn is_empty(&self) -> bool

Check if we’ve reached the end

Source

pub fn peek_is_string(&mut self) -> Result<bool>

Check if next non-whitespace character is a string quote

Source

pub fn parse_value(&mut self) -> Result<JsonValue>

Parse a complete JSON value

Source

pub fn parse_string(&mut self) -> Result<Cow<'a, str>>

Parse a string, returning a Cow to avoid allocation when possible

Source

pub fn parse_integer<T: ParseInt>(&mut self) -> Result<T>

Parse a signed integer directly from bytes without going through str::parse. Handles i8/i16/i32/i64/isize and u8/u16/u32/u64/usize via the ParseInt helper trait.

Source

pub fn parse_float<T: FromStr>(&mut self) -> Result<T>

Parse a floating-point number

Source

pub fn parse_bool(&mut self) -> Result<bool>

Parse a boolean value

Source

pub fn skip_whitespace_pub(&mut self)

Skip whitespace (public version for traits)

Source

pub fn peek_is_null(&mut self) -> bool

Check if next value is null (without consuming)

Source

pub fn has_next_array_element_or_first( &mut self, is_first: bool, ) -> Result<bool>

Check for next array element, handling first element specially

Source

pub fn expect_object_start(&mut self) -> Result<()>

Expect and consume ‘{’

Source

pub fn expect_object_end(&mut self) -> Result<()>

Expect and consume ‘}’

Source

pub fn expect_array_start(&mut self) -> Result<()>

Expect and consume ‘[’

Source

pub fn expect_array_end(&mut self) -> Result<()>

Expect and consume ‘]’

Source

pub fn expect_comma(&mut self) -> Result<()>

Expect and consume ‘,’

Source

pub fn expect_null(&mut self) -> Result<()>

Expect and consume ‘null’

Source

pub fn next_object_key(&mut self) -> Result<Option<Cow<'a, str>>>

Get the next object key, or None if at end of object

Source

pub fn has_next_array_element(&mut self) -> Result<bool>

Check if there’s another array element

Source

pub fn skip_value(&mut self) -> Result<()>

Skip a value (for unknown fields) without allocating

Auto Trait Implementations§

§

impl<'a> Freeze for JsonParser<'a>

§

impl<'a> RefUnwindSafe for JsonParser<'a>

§

impl<'a> Send for JsonParser<'a>

§

impl<'a> Sync for JsonParser<'a>

§

impl<'a> Unpin for JsonParser<'a>

§

impl<'a> UnsafeUnpin for JsonParser<'a>

§

impl<'a> UnwindSafe for JsonParser<'a>

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>,

Source§

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>,

Source§

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.