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