Expand description
This library provides a strict JSON parser as defined by
RFC 8259 and
ECMA-404.
Parsing values generates a CodeMap
that keeps track of the position of
each JSON value fragment in the parsed document.
§Features
- Strict implementation of RFC 8259 and ECMA-404.
- No stack overflow, your memory is the limit.
- Numbers are stored in lexical form thanks to the
json-number
crate, their precision is not limited. - Duplicate values are preserved. A JSON object is just a list of entries, in the order of definition.
- Strings are stored on the stack whenever possible, thanks to the
smallstr
crate. - The parser is configurable to accept documents that do not strictly adhere to the standard.
- Highly configurable printing methods.
- Macro to build any value statically.
- JSON Canonicalization Scheme implementation (RFC 8785)
enabled with the
canonicalization
feature. serde
support (by enabling theserde
feature).- Conversion from/to
serde_json::Value
(by enabling theserde_json
feature). - Thoroughly tested.
§Usage
use std::fs;
use json_syntax::{Value, Parse, Print};
let filename = "tests/inputs/y_structure_500_nested_arrays.json";
let input = fs::read_to_string(filename).unwrap();
let mut value = Value::parse_str(&input).expect("parse error").0;
println!("value: {}", value.pretty_print());
Re-exports§
pub use code_map::CodeMap;
pub use parse::Parse;
pub use print::Print;
pub use kind::Kind;
pub use kind::KindSet;
pub use array::Array;
pub use object::Object;
Modules§
Macros§
- json
- Constructs a
json_syntax::Value
from a JSON literal.
Structs§
- Invalid
Number - Invalid number error.
- KeySerializer
- Number
- Lexical JSON number.
- Number
Type - Serialize
Array - Serialize
Struct Variant - Serialize
Tuple Variant - Serializer
Value
serializer.- String
Number Serializer - Traverse
- Unexpected
- Unexpected JSON value kind error.
- Unordered
- Wrapper to view a value without considering the order of the objects entries.
Enums§
Constants§
- NUMBER_
CAPACITY - Number buffer stack capacity.
- SMALL_
STRING_ CAPACITY - String stack capacity.
Traits§
- Borrow
Unordered - TryFrom
Json - Conversion from JSON syntax, with code mapping info.
- TryFrom
Json Object - Conversion from JSON syntax object, with code mapping info.
- Unordered
Eq - Unordered
Hash - Unordered
Partial Eq
Functions§
- from_
value - Deserializes the JSON
value
into an instance of typeT
. - get_
array_ fragment - to_
value - Serializes the given
value
into a JSONValue
.