arson/
lib.rs

1#![deny(missing_debug_implementations)]
2#![deny(missing_docs)]
3
4//! # arson
5//!
6//! **arson** is a simple rust json library for parsing string. it has nice formatted colored output
7//!
8//! ## Example
9//!
10//! ```rust
11//! use arson::{JSONError, Parser, JSON, JSON::*};
12//!
13//! fn main() -> Result<(), JSONError> {
14//!     // alternative A
15//!     let json_str = std::fs::read_to_string("ex.json").unwrap();
16//!     // alternative B
17//!     let json_str = r#"{
18//!         "name": "John Doe",
19//!         "age": 43,
20//!         "address": {
21//!             "street": "10 Downing Street",
22//!             "city": "London"
23//!         },
24//!         "phones": [
25//!             "+44 1234567",
26//!             "+44 2345678"
27//!         ]
28//!     } "#;
29//!
30//!     // alternative 1
31//!     let json = json_str.parse::<JSON>().expect("Failed to parse json");
32//!     // alternative 2
33//!     let json = Parser::parse(json_str.chars())?;
34//!
35//!     println!("{:?}", json);
36//!
37//!     match json {
38//!         Array(val) => {}  // Vec<JSON>
39//!         Object(val) => {} // HashMap<String, JSON>
40//!         String(val) => {} // String
41//!         Number(val) => {} // f64
42//!         Bool(val) => {}   // bool
43//!         Null => {}
44//!     }
45//!
46//!     Ok(())
47//! }
48//! ```
49//!
50//! Output
51//!
52//! ```
53//! {
54//!     "address": {
55//!         "city": "London",
56//!         "street": "10 Downing Street",
57//!     },
58//!     "name": "John Doe",
59//!     "age": 43,
60//!     "phones": [
61//!         +44 1234567,
62//!         +44 2345678,
63//!     ],
64//! }
65//! ```
66
67mod json;
68mod json_error;
69mod parser;
70
71pub use json::JSON;
72pub use json_error::JSONError;
73pub use parser::Parser;