use crate::lib::{json, Value};
use crate::internal::{type_name};
pub fn x_to_lower_x(s: &str) -> String {
s.to_lowercase()
}
pub fn x_to_lower(s: &str) -> Value {
json!(x_to_lower_x(s))
}
pub fn to_lower_x(v: Value) -> String {
match v {
Value::Null => "".into(),
Value::Bool(b) => {
if b {
"true".into()
} else {
"false".into()
}
}
Value::String(s) => x_to_lower_x(&s),
Value::Number(n) => n.to_string(),
Value::Array(vec) => {
let mut result = vec![];
for item in vec.into_iter() {
if item.is_null() {
result.push("null".into())
} else {
result.push(to_lower_x(item));
}
}
result.join(",")
}
Value::Object(o) => x_to_lower_x(type_name(&o)),
}
}
pub fn to_lower(v: Value) -> Value {
Value::String(to_lower_x(v))
}
#[macro_export]
macro_rules! x_to_lower_x {
() => {
"".to_owned()
};
($a:expr $(,)*) => {
$crate::x_to_lower_x($a)
};
($a:expr, $($rest:tt)*) => {
$crate::x_to_lower_x($a)
};
}
#[macro_export]
macro_rules! x_to_lower {
() => {
json!("")
};
($a:expr $(,)*) => {
$crate::x_to_lower($a)
};
($a:expr, $($rest:tt)*) => {
$crate::x_to_lower($a)
};
}
#[macro_export]
macro_rules! to_lower_x {
() => {
"".to_owned()
};
($a:expr $(,)*) => {
$crate::to_lower_x($a)
};
($a:expr, $($rest:tt)*) => {
$crate::to_lower_x($a)
};
}
#[macro_export]
macro_rules! to_lower {
() => {
json!("")
};
($a:expr $(,)*) => {
$crate::to_lower($a)
};
($a:expr, $($rest:tt)*) => {
$crate::to_lower($a)
};
}