chisel_parsers/json/mod.rs
1use chisel_lexers::json::numerics::LazyNumeric;
2use std::borrow::Cow;
3use std::fmt::Debug;
4
5/// The JSON DOM parser
6pub mod dom;
7
8pub mod events;
9/// The JSON SAX parser
10pub mod sax;
11#[cfg(test)]
12pub(crate) mod specs;
13
14/// Enumeration of possible numeric types. Lazy numerics will be returned by the lexer backend if
15/// the associated feature is enabled, otherwise either floats or integer numerics are spat out
16#[derive(Debug, Clone)]
17pub enum JsonNumeric {
18 Float(f64),
19 Integer(i64),
20 Lazy(LazyNumeric),
21}
22
23/// Structure representing a JSON key value pair
24#[derive(Debug, Clone)]
25pub struct JsonKeyValue<'a> {
26 /// The key for the pair
27 pub key: String,
28 /// The JSON value
29 pub value: JsonValue<'a>,
30}
31
32/// Basic enumeration of different Json values
33#[derive(Debug, Clone)]
34pub enum JsonValue<'a> {
35 /// Map of values
36 Object(Vec<JsonKeyValue<'a>>),
37 /// Array of values
38 Array(Vec<JsonValue<'a>>),
39 /// Canonical string value
40 String(Cow<'a, str>),
41 /// Number value which will be a member of the union [JsonNumeric]
42 Number(JsonNumeric),
43 /// Floating point numeric value
44 Float(f64),
45 /// Integer numeric value
46 Integer(i64),
47 /// Canonical boolean value
48 Boolean(bool),
49 /// Canonical null value
50 Null,
51}