I have hash deep nested hash and i want the hierarchy(parent to child) for each key as an array.
for example -
hash = {
"properties"=>{
"one"=>"extra",
"headers"=>{
"type"=>"object",
"type1"=>"object2"
},
"entity"=>{
"type"=>"entype"
},
},
"sec_prop"=>"hmmm"
}
for this hash I want output as given below, as a separate array for each key.
[properties,one]
[properties,headers,type]
[properties,headers,type1]
[properties,entity,type]
[sec_prop]
i have been trying and searching this for so long through some recursive methods but it doesn't seems to work for me any help will be appreciated.
important thing to notice here is there are duplicate keys in the same hash as a nesting for example type key is repeated in both headers and entity. so that i need proper hierarchy to identify the proper key
and i should get this array of hierarchy only for those keys whose value is not a another hash.
It should be in the format above given but any other solutions also welcome
thanks.!