16 releases

0.9.1 Mar 9, 2023
0.9.0 Dec 21, 2022
0.8.18 Dec 19, 2022
0.8.14 Nov 3, 2022
0.6.1 Jul 15, 2022

#197 in Data structures

Download history 125/week @ 2022-12-09 160/week @ 2022-12-16 86/week @ 2022-12-23 32/week @ 2022-12-30 99/week @ 2023-01-06 103/week @ 2023-01-13 101/week @ 2023-01-20 92/week @ 2023-01-27 123/week @ 2023-02-03 191/week @ 2023-02-10 341/week @ 2023-02-17 318/week @ 2023-02-24 332/week @ 2023-03-03 180/week @ 2023-03-10 317/week @ 2023-03-17 299/week @ 2023-03-24

1,155 downloads per month
Used in 26 crates (7 directly)

MIT/Apache

160KB
5K 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

~4MB
~76K SLoC