Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last month.
I have to translate an array to nested dictionary.
In case i have a string array. each string combined from numbers that seprated by dots, and each number means a key in the translated dictionary. (except the last number)
e.g.
i have this array:
array = ["5.1.1.1","5.1.1.2","5.1.1.3",..."5.2.1.2","5.2.1.4"..."1.1.1.1"..."1.2.1.3"]
and i need output to be this:
var output = {
'5': {
'1': {
'1': [1,2,3],
'2': [1]
},
'2':{
'1': [2,4],
'2': [1]
}
},
'1': {
'1':{
'1':[1,2,5],
'2':[1]
},
'2':{
'1':[2,3]
}
}
};
i have an opposite function, which get a nested dictionary and her output is an array.
link: https://stackoverflow.com/a/59191937/7593555
Thanks for helping :).