neco-json5 0.1.0

zero dependency JSON5 subset parser
Documentation
  • Coverage
  • 8.33%
    1 out of 12 items documented1 out of 4 items with examples
  • Size
  • Source code size: 17.65 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 404.72 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • barineco/neco-parser
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • barineco

neco-json5

日本語

zero dependency JSON5 subset parser.

Features

  • Object parsing with unquoted, single-quoted, or double-quoted keys
  • Scalar parsing for null, bool, number, and string values
  • Array parsing with comma-separated scalar values
  • Object fields stored in source order as Vec<(String, Json5Value)>
  • ParseError with byte-oriented position and message

Usage

Parse

use neco_json5::{parse, Json5Value};

let value = parse("{name: 'neco'}").unwrap();
assert!(matches!(value, Json5Value::Map(_)));

Read fields

use neco_json5::{parse, Json5Value};

let value = parse("{name: 'neco'}").unwrap();
let Json5Value::Map(fields) = value else { panic!("map") };
assert!(fields.iter().any(|(key, value)| {
    key == "name" && matches!(value, Json5Value::String(text) if text == "neco")
}));

API

Item Description
parse(input: &str) -> Result<Json5Value, ParseError> Parses the supported JSON5 subset
Json5Value Null, Bool, Number(f64), String, List, or ordered Map
ParseError Reports byte position and message

Format support

The supported subset covers configuration-shaped JSON5 object documents, common scalar values, and scalar arrays. It keeps duplicate object keys in order and does not implement the full JSON5 grammar.

License

MIT