json-syntax 0.5.1

Strict JSON parsing and mapping library
Documentation

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.
  • Thoroughly tested.

Usage

use std::fs;
use json_syntax::{Value, Parse};
use decoded_char::DecodedChars;
use locspan::Loc;

fn infallible<T>(t: T) -> Result<T, std::convert::Infallible> {
  Ok(t)
}

let filename = "tests/inputs/y_structure_500_nested_arrays.json";
let input = fs::read_to_string(filename).unwrap();
let Loc(value, value_location) = Value::parse(filename, input.decoded_chars().map(infallible)).expect("parse error");

// ...

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.