buni-rs 1.0.0

Reference Buni deserializer in Rust
Documentation
pub const SPECIAL_CHARACTERS: &str = "()\":";

pub fn escape_buni(str: &str) -> String {
    if numerical(str)
        || str.contains(|c| {
        SPECIAL_CHARACTERS.contains(c)
    })
        || str == "True"
        || str == "true"
        || str == "False"
        || str == "false"
        || str == "None"
        || str == "none"
    {
        format!("\"{}\"", str)
    } else {
        str.to_string()
    }
}

pub fn numerical(str: &str) -> bool {
    for char in str.chars() {
        if !char.is_numeric() {
            return false;
        }
    }
    true
}