35 releases

0.12.5 Jul 3, 2024
0.12.3 Apr 2, 2024
0.12.2 Feb 21, 2024
0.10.0 Oct 19, 2023
0.6.1 Jul 15, 2022

#201 in Parser implementations

Download history 5941/week @ 2024-07-25 6059/week @ 2024-08-01 6411/week @ 2024-08-08 5850/week @ 2024-08-15 5610/week @ 2024-08-22 6624/week @ 2024-08-29 6899/week @ 2024-09-05 6242/week @ 2024-09-12 6304/week @ 2024-09-19 5923/week @ 2024-09-26 6426/week @ 2024-10-03 6631/week @ 2024-10-10 7393/week @ 2024-10-17 6891/week @ 2024-10-24 6092/week @ 2024-10-31 3614/week @ 2024-11-07

24,911 downloads per month
Used in 80 crates (28 directly)

MIT/Apache

190KB
6K SLoC

Strict JSON parsing and mapping library

CI Crate informations License Documentation

This library provides a strict JSON parser as defined by RFC 8259 and ECMA-404. It is built on the locspan library so as to keep track of the position of each JSON value 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 the serde 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, |span| span).expect("parse error");
println!("value: {}", value.pretty_print());

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~5MB
~96K SLoC