pub struct JsonParser<'a> { /* private fields */ }Expand description
High-performance JSON parser
Implementations§
Source§impl<'a> JsonParser<'a>
impl<'a> JsonParser<'a>
Sourcepub fn from_bytes(input: &'a [u8]) -> Self
pub fn from_bytes(input: &'a [u8]) -> Self
Create a new parser from bytes
Sourcepub fn peek_is_string(&mut self) -> Result<bool>
pub fn peek_is_string(&mut self) -> Result<bool>
Check if next non-whitespace character is a string quote
Sourcepub fn parse_value(&mut self) -> Result<JsonValue>
pub fn parse_value(&mut self) -> Result<JsonValue>
Parse a complete JSON value
Sourcepub fn parse_string(&mut self) -> Result<Cow<'a, str>>
pub fn parse_string(&mut self) -> Result<Cow<'a, str>>
Parse a string, returning a Cow to avoid allocation when possible
Sourcepub fn parse_integer<T: ParseInt>(&mut self) -> Result<T>
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.
Sourcepub fn parse_float<T: FromStr>(&mut self) -> Result<T>
pub fn parse_float<T: FromStr>(&mut self) -> Result<T>
Parse a floating-point number
Sourcepub fn parse_bool(&mut self) -> Result<bool>
pub fn parse_bool(&mut self) -> Result<bool>
Parse a boolean value
Sourcepub fn skip_whitespace_pub(&mut self)
pub fn skip_whitespace_pub(&mut self)
Skip whitespace (public version for traits)
Sourcepub fn peek_is_null(&mut self) -> bool
pub fn peek_is_null(&mut self) -> bool
Check if next value is null (without consuming)
Sourcepub fn has_next_array_element_or_first(
&mut self,
is_first: bool,
) -> Result<bool>
pub fn has_next_array_element_or_first( &mut self, is_first: bool, ) -> Result<bool>
Check for next array element, handling first element specially
Sourcepub fn expect_object_start(&mut self) -> Result<()>
pub fn expect_object_start(&mut self) -> Result<()>
Expect and consume ‘{’
Sourcepub fn expect_object_end(&mut self) -> Result<()>
pub fn expect_object_end(&mut self) -> Result<()>
Expect and consume ‘}’
Sourcepub fn expect_array_start(&mut self) -> Result<()>
pub fn expect_array_start(&mut self) -> Result<()>
Expect and consume ‘[’
Sourcepub fn expect_array_end(&mut self) -> Result<()>
pub fn expect_array_end(&mut self) -> Result<()>
Expect and consume ‘]’
Sourcepub fn expect_comma(&mut self) -> Result<()>
pub fn expect_comma(&mut self) -> Result<()>
Expect and consume ‘,’
Sourcepub fn expect_null(&mut self) -> Result<()>
pub fn expect_null(&mut self) -> Result<()>
Expect and consume ‘null’
Sourcepub fn next_object_key(&mut self) -> Result<Option<Cow<'a, str>>>
pub fn next_object_key(&mut self) -> Result<Option<Cow<'a, str>>>
Get the next object key, or None if at end of object
Sourcepub fn has_next_array_element(&mut self) -> Result<bool>
pub fn has_next_array_element(&mut self) -> Result<bool>
Check if there’s another array element
Sourcepub fn skip_value(&mut self) -> Result<()>
pub fn skip_value(&mut self) -> Result<()>
Skip a value (for unknown fields) without allocating