I am currently working with a nested dictionary and my goal is to convert it into a list of strings. For example, the initial input looks like this:
var group = {
'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]
}
}
};
The desired output should be:
a = ["5.1.1.1", "5.1.1.2", "5.1.1.3"..... "1.2.1.3"]
To achieve this, I began by creating a recursive function:
function printValues(obj) {
for (var key in obj) {
console.log(key)
if (typeof obj[key] === "object") {
printValues(obj[key]);
} else {
console.log(obj[key]);
}
}
}
However, the function is not producing the expected result yet..