Expand description
High-performance zero-allocation JSON iterator and validator.
A faithful Rust port of romshark/jscan/v2.
§Example
use jscan::{scan, scan_str, ValueType};
// Works with &[u8]
let json = br#"{"name":"Alice","age":30}"#;
let err = scan(json, |iter| {
println!("{}: {:?}", iter.pointer(), iter.value_type());
false // continue scanning
});
assert!(err.is_none());
// Also works with &str via scan_str
let json = r#"{"name":"Alice","age":30}"#;
let err = scan_str(json, |iter| {
if iter.value_type() == ValueType::Number {
println!("{} = {}", iter.pointer(), iter.value_str());
}
false
});
assert!(err.is_none());Structs§
- Error
- A JSON syntax error with location information.
- Iterator
- Provides access to the current JSON value during scanning.
- Parser
- Reusable parser. More efficient than the free functions for multiple inputs.
- Validator
- Reusable JSON validator. More efficient than the free functions when validating multiple inputs.
Enums§
Functions§
- scan
- Scan
sas one complete JSON value, callingffor each encountered value. ReturnsNoneon success, orSome(Error)on failure. - scan_
one - Scan one JSON value from the start of
s, callingffor each encountered value. Returns(remaining, Option<Error>). - scan_
str - Like
scan, but accepts&strdirectly. - valid
- Returns
trueifsis valid JSON. - valid_
str - Like
valid, but accepts&strdirectly. - validate
- Validate that
sis exactly one valid JSON value. - validate_
one - Validate one JSON value from the start of
s. - validate_
str - Like
validate, but accepts&strdirectly.