fn deep_flaten_json(past_key: String, val: Value, past_memory: &mut HashMap<String, Vec<String>>) {
    let mut collect_memory = |key: String, value: String| {
        if let Some(vals) = past_memory.get_mut(&key) {
            vals.push(value);
            return;
        }
        past_memory.insert(key, vec![value]);
        return;
    };

    match val {
        Value::Object(mut obj) => {
            for (key, value) in obj.drain() {
                deep_flaten_json(format!("{}.{}", past_key, key), value, past_memory);
            }
        }
        Value::Static(val) => {
            collect_memory(past_key, convert_static_node_to_string(val).unwrap());
        }
        Value::String(val) => {
            collect_memory(past_key, val.into_owned());
        }
        Value::Array(vals) => {
            for val in vals {
                deep_flaten_json(past_key.clone(), val, past_memory);
            }
        }
    }
}
/// deep_flaten_json will deep traverse and flatten the json.
deep_flaten_json will deep traverse and flatten the json.
deep_flaten_json will deep traverse and flatten the json .
fn deep_flaten_json(past_key: String, val: Value, past_memory: &mut HashMap<String, Vec<String>>) {
    let mut collect_memory = |key: String, value: String| {
        if let Some(vals) = past_memory.get_mut(&key) {
            vals.push(value);
            return;
        }
        past_memory.insert(key, vec![value]);
        return;
    };
    match val {
        Value::Object(mut obj) => {
            for (key, value) in obj.drain() {
                deep_flaten_json(format!("{}.{}", past_key, key), value, past_memory);
            }
        }
        Value::Static(val) => {
            collect_memory(past_key, convert_static_node_to_string(val).unwrap());
        }
        Value::String(val) => {
            collect_memory(past_key, val.into_owned());
        }
        Value::Array(vals) => {
            for val in vals {
                deep_flaten_json(past_key.clone(), val, past_memory);
            }
        }
    }
}
fn deep_flaten_json ( past_key : String , val : Value , past_memory : & mut HashMap < String , Vec < String > > ) { let mut collect_memory = | key : String , value : String | { if let Some ( vals ) = past_memory . get_mut ( & key ) { vals . push ( value ) ; return ; } past_memory . insert ( key , vec ! [ value ] ) ; return ; } ; match val { Value :: Object ( mut obj ) => { for ( key , value ) in obj . drain ( ) { deep_flaten_json ( format ! ( " " past_key key ) , value , past_memory ) ; } } Value :: Static ( val ) => { collect_memory ( past_key , convert_static_node_to_string ( val ) . unwrap ( ) ) ; } Value :: String ( val ) => { collect_memory ( past_key , val . into_owned ( ) ) ; } Value :: Array ( vals ) => { for val in vals { deep_flaten_json ( past_key . clone ( ) , val , past_memory ) ; } } } }
deep_flaten_json will deep traverse and flatten the json.
deep_flaten_json will deep traverse and flatten the json .
past_key
String
val
Value
past_memory
&mut HashMap<String, Vec<String>>