yan_json 0.2.2

A lightweight library for easily handling JSON
Documentation
mod serialization;
mod deserialization;

mod macros;

/// this module to simplify the process of importing stuff from yan_json
/// it's intended to be used like this:
/// ```
/// use yan_json::prelude::*;
/// ```
pub mod prelude;

use prelude::*;

#[cfg(test)]
mod tests;


/// this is the most important struct in this extern crate
///
/// # Expamples
/// ```
/// use yan_json::prelude::*;
///
/// // deserialize like this:
/// let api_data_raw = r#"{"data": ["this", "is", "data"], "time in ms": 100}"#;
/// let api_data_json = JsonNode::parse(api_data_raw).unwrap();
/// assert_eq!(api_data_json, json!({
///     "data": ["this", "is", "data"],
///     "time in ms": 100
/// }));
///
/// // serialize like this:
/// let response_json = json!({
///     "response": "this is a response",
///     "valid": true,
///     "error": null
/// });
/// let response_raw = response_json.to_string();
/// assert_eq!(JsonNode::parse(&response_raw), Some(response_json));
/// ```
#[derive(Debug, PartialEq)]
pub enum JsonNode {
    Object(HashMap<String, Self>),
    Array(Vec<Self>),
    String(String),
    Number(f64),
    Bool(bool),
    Null,
}