I have a json object with three level of nesting I have to Iterate it Dynamically
Here is my code
var responseObj ={
db_config:{
db_user: 'das1234',
},
env_con:{
db_con:'ds67'
},
db_password: 'ds345ty76',
db_host: 'wdsa12'
}
function decrypt(responseObj,key){
var list = []
//get the keys from the responseObj
Object.keys(responseObj).forEach(function(key){
//Push the keys into a list
list.push(key);
})
console.log(list)
try{
for(var i =0;i<list.length;i++){
//Decrypt the values of the key
var decipher = crypto.createDecipher('aes256', key);
//Assign The decrypted value to the keys
responseObj[list[i]] = decipher.update(responseObj[list[i]], 'hex', 'utf8') + decipher.final('utf8')
}
return responseObj;
}catch(err){
console.log(err);
}
}
var res = decrypt(responseObj,key)
console.log(res)
had tried lot ways I just confused How to get the keys and values as iterated dynamically without using the key as static. Have any Idea about pls help to find it out.