Expand description

Classification of bytes withing JSON quote sequences.

Provides the QuoteClassifiedBlock struct and QuoteClassifiedIterator trait that allow effectively enriching JSON inputs with quote sequence information.

The output of quote classification is an iterator of QuoteClassifiedBlock which contain bitmasks whose lit bits signify characters that are within quotes in the source document. These characters need to be ignored.

Note that the actual quote characters are not guaranteed to be classified as “within themselves” or otherwise. In particular the current implementation marks opening quotes with lit bits, but closing quotes are always unmarked. This behavior should not be presumed to be stable, though, and can change without a major semver bump.

Examples

use rsonpath_lib::classification::quotes::{classify_quoted_sequences, QuoteClassifiedIterator};
use aligners::AlignedBytes;

let json = r#"{"x": "string", "y": {"z": "\"escaped\""}}"#;
//            011000111111100011000011000111111111111000
// The mask below appears reversed due to endianness.
let expd = 0b000111111111111000110000110001111111000110;
let aligned = AlignedBytes::new_padded(json.as_bytes());
let mut quote_classifier = classify_quoted_sequences(&aligned);

let block = quote_classifier.next().unwrap();
assert_eq!(expd, block.within_quotes_mask);

Structs

Traits

  • Trait for quote classifier iterators, i.e. finite iterators enriching blocks of input with quote bitmasks. Iterator is allowed to hold a reference to the JSON document valid for 'a.

Functions