pub fn to_json(toml: Toml) -> Json {
    match toml {
        Toml::String(s) => Json::String(s),
        Toml::Integer(i) => Json::Number(i.into()),
        Toml::Float(f) => {
            let n = serde_json::Number::from_f64(f).expect("float infinite and nan not allowed");
            Json::Number(n)
        }
        Toml::Boolean(b) => Json::Bool(b),
        Toml::Array(arr) => Json::Array(arr.into_iter().map(to_json).collect()),
        Toml::Table(table) => {
            Json::Object(table.into_iter().map(|(k, v)| (k, to_json(v))).collect())
        }
        Toml::Datetime(dt) => Json::String(dt.to_string()),
    }
}
/// A helper function to parse the TOML into a JSON.
A helper function to parse the TOML into a JSON.
A helper function to parse the TOML into a JSON .
pub fn to_json(toml: Toml) -> Json {
    match toml {
        Toml::String(s) => Json::String(s),
        Toml::Integer(i) => Json::Number(i.into()),
        Toml::Float(f) => {
            let n = serde_json::Number::from_f64(f).expect("float infinite and nan not allowed");
            Json::Number(n)
        }
        Toml::Boolean(b) => Json::Bool(b),
        Toml::Array(arr) => Json::Array(arr.into_iter().map(to_json).collect()),
        Toml::Table(table) => {
            Json::Object(table.into_iter().map(|(k, v)| (k, to_json(v))).collect())
        }
        Toml::Datetime(dt) => Json::String(dt.to_string()),
    }
}
pub fn to_json ( toml : Toml ) -> Json { match toml { Toml :: String ( s ) => Json :: String ( s ) , Toml :: Integer ( i ) => Json :: Number ( i . into ( ) ) , Toml :: Float ( f ) => { let n = serde_json :: Number :: from_f64 ( f ) . expect ( " " ) ; Json :: Number ( n ) } Toml :: Boolean ( b ) => Json :: Bool ( b ) , Toml :: Array ( arr ) => Json :: Array ( arr . into_iter ( ) . map ( to_json ) . collect ( ) ) , Toml :: Table ( table ) => { Json :: Object ( table . into_iter ( ) . map ( | ( k , v ) | ( k , to_json ( v ) ) ) . collect ( ) ) } Toml :: Datetime ( dt ) => Json :: String ( dt . to_string ( ) ) , } }
A helper function to parse the TOML into a JSON.
A helper function to parse the TOML into a JSON .
toml
Toml
toml
Toml