I hope you are very well.
I am trying to find an complex object in an Object in Angular from a String (the content of this String is dynamic).
For example:
let variable = {
"name":"Rick",
"family": {
"son":"Andy"
}
};
When I try to read the name attribute, I can find it with the code:
console.log(variable["name"]);
When I try to read the family attribute, I can find it with the code:
console.log(variable["family"]);
However when I try to read the son attribute, I have tried to make with the code:
console.log(variable["family.son"]);
But I have gotten an undefined value, I found that I can use any of the followings codes:
console.log(variable["family"]["son"]);
console.log(variable["family"].son);
But it is not working for me, because I need to search the attribute from a String (the attributes are Dynamics), Does someone know how can I solve this.
The String contains the attribute path, for instance: "family.son" or "family"
Regards.