Struct jsonl_converter::processor::Processor
source · pub struct Processor { /* private fields */ }
Expand description
This struct contains the functionality to process a stream of bytes to convert JSON to JSONL. It keeps track of the brackets that have been opened but not closed, as well as the JSONL string that is being built.
Fields
bracket_stack
- A stack of brackets that have been opened but not closed.jsonl_string
- The JSONL string that is being built.
Examples
Implementations§
source§impl Processor
impl Processor
sourcepub fn push_bracket(&mut self, byte: &char)
pub fn push_bracket(&mut self, byte: &char)
sourcepub fn process_char(&mut self, byte: &char)
pub fn process_char(&mut self, byte: &char)
Processes a character. This function will either add the character to the
jsonl_string
or print the jsonl_string
if the character is a closing
bracket and the bracket_stack
is empty (except for the initial
opening bracket).
Arguments
byte
- A character.
Examples
use jsonl_converter::processor::Processor;
let mut processor = Processor::new();
processor.push_bracket(&'[');
processor.process_char(&'{');
processor.process_char(&'a');
processor.process_char(&':');
processor.process_char(&'1');
processor.process_char(&'}');