fn convert_from_json(v: &serde_json::value::Value) -> Value {
    match &*v {
        serde_json::value::Value::Null => Value::Null,
        serde_json::value::Value::Bool(true) => Value::Int(1),
        serde_json::value::Value::Bool(false) => Value::Int(0),
        serde_json::value::Value::Number(n) => {
            if n.is_i64() {
                let n_uw = n.as_i64().unwrap();
                let n2_res = i32::try_from(n_uw);
                match n2_res {
                    Ok(n2) => {
                        Value::Int(n2)
                    }
                    _ => {
                        Value::BigInt(n_uw.to_bigint().unwrap())
                    }
                }
            } else if n.is_u64() {
                let n_uw = n.as_u64().unwrap();
                let n2_res = i32::try_from(n_uw);
                match n2_res {
                    Ok(n2) => {
                        Value::Int(n2)
                    }
                    _ => {
                        Value::BigInt(n_uw.to_bigint().unwrap())
                    }
                }
            } else {
                Value::Float(n.as_f64().unwrap())
            }
        }
        serde_json::value::Value::String(s) => {
            eprintln!("string {}", s);
            Value::String(s.to_string(), None)
        }
        serde_json::value::Value::Array(lst) => Value::List(
            lst.iter()
                .map(|v| Rc::new(RefCell::new(convert_from_json(v))))
                .collect::<VecDeque<_>>(),
        ),
        serde_json::value::Value::Object(map) => Value::Hash(
            map.iter()
                .map(|(k, v)| {
                    (k.to_string(), Rc::new(RefCell::new(convert_from_json(v))))
                })
                .collect::<IndexMap<_, _>>(),
        ),
    }
}
/// Converts a serde_json object into a value.
Converts a serde_json object into a value.
Converts a serde_json object into a value .
fn convert_from_json(v: &serde_json::value::Value) -> Value {
    match &*v {
        serde_json::value::Value::Null => Value::Null,
        serde_json::value::Value::Bool(true) => Value::Int(1),
        serde_json::value::Value::Bool(false) => Value::Int(0),
        serde_json::value::Value::Number(n) => {
            if n.is_i64() {
                let n_uw = n.as_i64().unwrap();
                let n2_res = i32::try_from(n_uw);
                match n2_res {
                    Ok(n2) => {
                        Value::Int(n2)
                    }
                    _ => {
                        Value::BigInt(n_uw.to_bigint().unwrap())
                    }
                }
            } else if n.is_u64() {
                let n_uw = n.as_u64().unwrap();
                let n2_res = i32::try_from(n_uw);
                match n2_res {
                    Ok(n2) => {
                        Value::Int(n2)
                    }
                    _ => {
                        Value::BigInt(n_uw.to_bigint().unwrap())
                    }
                }
            } else {
                Value::Float(n.as_f64().unwrap())
            }
        }
        serde_json::value::Value::String(s) => {
            eprintln!("string {}", s);
            Value::String(s.to_string(), None)
        }
        serde_json::value::Value::Array(lst) => Value::List(
            lst.iter()
                .map(|v| Rc::new(RefCell::new(convert_from_json(v))))
                .collect::<VecDeque<_>>(),
        ),
        serde_json::value::Value::Object(map) => Value::Hash(
            map.iter()
                .map(|(k, v)| {
                    (k.to_string(), Rc::new(RefCell::new(convert_from_json(v))))
                })
                .collect::<IndexMap<_, _>>(),
        ),
    }
}
fn convert_from_json ( v : & serde_json :: value :: Value ) -> Value { match & * v { serde_json :: value :: Value :: Null => Value :: Null , serde_json :: value :: Value :: Bool ( true ) => Value :: Int ( 1 ) , serde_json :: value :: Value :: Bool ( false ) => Value :: Int ( 0 ) , serde_json :: value :: Value :: Number ( n ) => { if n . is_i64 ( ) { let n_uw = n . as_i64 ( ) . unwrap ( ) ; let n2_res = i32 :: try_from ( n_uw ) ; match n2_res { Ok ( n2 ) => { Value :: Int ( n2 ) } _ => { Value :: BigInt ( n_uw . to_bigint ( ) . unwrap ( ) ) } } } else if n . is_u64 ( ) { let n_uw = n . as_u64 ( ) . unwrap ( ) ; let n2_res = i32 :: try_from ( n_uw ) ; match n2_res { Ok ( n2 ) => { Value :: Int ( n2 ) } _ => { Value :: BigInt ( n_uw . to_bigint ( ) . unwrap ( ) ) } } } else { Value :: Float ( n . as_f64 ( ) . unwrap ( ) ) } } serde_json :: value :: Value :: String ( s ) => { eprintln ! ( " " s ) ; Value :: String ( s . to_string ( ) , None ) } serde_json :: value :: Value :: Array ( lst ) => Value :: List ( lst . iter ( ) . map ( | v | Rc :: new ( RefCell :: new ( convert_from_json ( v ) ) ) ) . collect :: < VecDeque < _ > > ( ) , ) , serde_json :: value :: Value :: Object ( map ) => Value :: Hash ( map . iter ( ) . map ( | ( k , v ) | { ( k . to_string ( ) , Rc :: new ( RefCell :: new ( convert_from_json ( v ) ) ) ) } ) . collect :: < IndexMap < _ , _ > > ( ) , ) , } }
Converts a serde_json object into a value.
Converts a serde_json object into a value .
v
&serde_json::value::Value