parse_streaming

Function parse_streaming 

Source
pub fn parse_streaming<'a>(
    input: &'a str,
) -> Result<StreamingParser<'a>, ParseError>
Expand description

Parses a JSON string slice into a StreamingParser.

This is the main entry point for the streaming parser. It’s fast, low-allocation, and operates as an Iterator over ParserEvents.

§Arguments

  • input - A string slice containing the JSON data to be parsed.

§Errors

Returns a ParseError if the input exceeds the MAX_JSON_SIZE_BYTES limit (10MB) before parsing begins.

§Examples

use rill_json::{parse_streaming, ParserEvent, JsonNumber};

let json_data = r#"[1, "hello"]"#;
let mut parser = parse_streaming(json_data).unwrap();

assert_eq!(parser.next().unwrap().unwrap(), ParserEvent::StartArray);
assert_eq!(parser.next().unwrap().unwrap(), ParserEvent::Number(JsonNumber::I64(1)));
assert_eq!(parser.next().unwrap().unwrap(), ParserEvent::String("hello".into()));
assert_eq!(parser.next().unwrap().unwrap(), ParserEvent::EndArray);
assert!(parser.next().is_none());