use indexmap::IndexMap;
use serde::Serialize;
use std::borrow::Cow;
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
pub use crate::de::{from_slice, from_str};
pub use crate::parser::{parse, Rule};
pub mod error;
mod parser;
mod de;
#[cfg(any(
feature = "lua",
feature = "lua51",
feature = "lua52",
feature = "lua53",
feature = "lua54",
feature = "luajit",
feature = "luajit52"
))]
mod lua;
#[cfg(feature = "wasm")]
mod wasm;
pub type Inputs<'a> = HashMap<&'a str, Value<'a>>;
#[derive(Serialize, Debug, Clone)]
#[serde(untagged)]
pub enum Value<'a> {
Object(IndexMap<&'a str, Value<'a>>),
Array(Vec<Value<'a>>),
String(Cow<'a, str>),
Integer(i64),
Float(f64),
Boolean(bool),
Null(Option<()>),
}
impl<'a> Display for Value<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Value::Object(_) => "object",
Value::Array(_) => "array",
Value::String(_) => "string",
Value::Integer(_) => "integer",
Value::Float(_) => "float",
Value::Boolean(_) => "boolean",
Value::Null(_) => "null",
}
)
}
}