chisel_json/
lib.rs

1//! ## Another JSON Parser?
2//!
3//! The Chisel JSON parser aims to be a relatively simple DOM and SAX parser for JSON, that does
4//! *not include* all the machinery required to support explicit serialisation from, and
5//! deserialisation into `structs`/`enums` within Rust.
6//!
7//! It's a simple little parser that is intended to allow you to choose how you want to parse a lump of *cursed* JSON,
8//! and then either build/transform a DOM into a richer AST structure, or alternatively just cherry-pick the useful
9//! bits of the payload via closures which are called in response to SAX parsing events.
10//!
11//! (*Because let's face it, JSON payloads usually come burdened with a whole load of unnecessary crap that
12//! you'll never use*).
13//!
14#![allow(unused_imports)]
15#![allow(dead_code)]
16
17extern crate core;
18
19use std::borrow::Cow;
20use std::collections::HashMap;
21
22pub mod coords;
23pub mod lexer;
24pub mod parsers;
25pub mod pointers;
26#[cfg(test)]
27mod test_macros;
28
29pub mod results;
30
31/// Structure representing a JSON key value pair
32#[derive(Debug)]
33pub struct JsonKeyValue<'a> {
34    /// The key for the pair
35    pub key: String,
36    /// The JSON value
37    pub value: JsonValue<'a>,
38}
39
40/// Basic enumeration of different Json values
41#[derive(Debug)]
42pub enum JsonValue<'a> {
43    /// Map of values
44    Object(Vec<JsonKeyValue<'a>>),
45    /// Array of values
46    Array(Vec<JsonValue<'a>>),
47    /// Canonical string value
48    String(Cow<'a, str>),
49    /// Floating point numeric value
50    Float(f64),
51    /// Integer numeric value
52    Integer(i64),
53    /// Canonical boolean value
54    Boolean(bool),
55    /// Canonical null value
56    Null,
57}