Posted to tcl by evilotto at Thu Jul 03 17:46:47 GMT 2014view pretty

proc dict_flatten {dictVal} {
    dict for {k v} $dictVal {
        if {[llength $v] % 2 == 0} {
            set dictVal [dict remove $dictVal[set dictVal {}] $k]
            dict for {sk sv} [dict_flatten $v] {
                dict set dictVal ${k}.${sk} $sv
            }
        }
    }
    return $dictVal
}