Am using foreach for iterate to first level.This is my Json object
{
"Parent1": [
{
"Data1": [
"Item1",
"Item2"
]
}
],
"Parent2": [
{
"Data2": [
"Item3",
"Item4"
]
}
]
}
.ts file
Object.keys(parent).forEach((key: any) => {
let value = parent[key];
tmpData = parent[key];
console.log(tmpData[0]);
});
above code will iterate the first level.How can i get below value?
"Data1": ["Item1",
"Item2"
]
Do i need to use nested fearch?
Do we have any other solutions?
Thanks in advance.
Expecting a better solution.
parent.Parent1. Are you trying to walk through properties of object of arbitrary depth like this or something? Please consider providing a minimal reproducible example that demonstrates your issue when pasted, as-is, into a standalone IDE. I'm happy to help but I am not sure what you are really trying to do.