I have following object:
var obj = {
"id": 1,
"name": "john",
"creds": {
"username": "abc@yopmail.com"
},
"account": {
"credit": {
"number": "123456"
},
"name": "accountName"
}
}
How can i dynamically get value:
I want to get the value by passing the hierarchy as string
console.log("Username: ", obj["creds.username"]);
console.log("CreditNumber: ", obj["account.credit.number"]);
Note: the object might have nth deep child objects
Please advise me a dynamic solution for this