My goal is to loop through all the objects stored in the "testmaps" data structure.
I attempted to iterate through "testmaps" initially, but it seems like instead of iterating through maps, I am looping through strings. This prevents me from accessing the nested objects properly.
JSON
{"testmap1":
[{"name":"testObject1","boolean1":true,"boolean2":true,"boolean3":false,"otherString":"test"},
{"name":"testObject2","boolean1":false,"boolean2":false,"boolean3":false,"otherString":"test2"}],
"testmap2":
[{"name":"testObject3","boolean1":false,"boolean2":false,"boolean3":false,"otherString":"test3"},
{"name":"testObject4","boolean1":false,"boolean2":true,"boolean3":false,"otherString":"test4"}]}
TypeScript code for reading the data:
ngOnInit() {
this.http.get('http://myURL').subscribe(
data => {
this.array = data;
console.log(this.array);
},
(err: HttpErrorResponse) => {
console.log(err.message);
}
);
}
This is how I tried to iterate in TypeScript:
ngDoCheck(){
for (let map in this.array) {
for (let item in map.valueOf){
console.log(item.otherString);
}
}
}
However, the loop I implemented doesn't produce any results.