/// Transforms the JSON Value type into a Number.
Transforms the JSON Value type into a Number.
Transforms the JSON Value type into a Number .
pub fn value_to_number(value: &Value) -> Option<Number> {
    use std::str::FromStr;
    match value {
        Value::Null => None,
        Value::Bool(boolean) => Some(Number::Unsigned(*boolean as u64)),
        Value::Number(number) => {
            match (number.as_i64(), number.as_u64(), number.as_f64()) {
                (Some(n), _, _) => Some(Number::Signed(n)),
                (_, Some(n), _) => Some(Number::Unsigned(n)),
                (_, _, Some(n)) => Some(Number::Float(OrderedFloat(n))),
                (None, None, None) => None,
            }
        },
        Value::String(string) => Number::from_str(string).ok(),
        Value::Array(_array) => None,
        Value::Object(_object) => None,
    }
}
pub fn value_to_number ( value : & Value ) -> Option < Number > { use std :: str :: FromStr ; match value { Value :: Null => None , Value :: Bool ( boolean ) => Some ( Number :: Unsigned ( * boolean as u64 ) ) , Value :: Number ( number ) => { match ( number . as_i64 ( ) , number . as_u64 ( ) , number . as_f64 ( ) ) { ( Some ( n ) , _ , _ ) => Some ( Number :: Signed ( n ) ) , ( _ , Some ( n ) , _ ) => Some ( Number :: Unsigned ( n ) ) , ( _ , _ , Some ( n ) ) => Some ( Number :: Float ( OrderedFloat ( n ) ) ) , ( None , None , None ) => None , } } , Value :: String ( string ) => Number :: from_str ( string ) . ok ( ) , Value :: Array ( _array ) => None , Value :: Object ( _object ) => None , } }
Transforms the JSON Value type into a Number.
Transforms the JSON Value type into a Number .
value
&Value