You need to implement a custom pipe to do this. ngFor only supports array and not object.

This pipe will look like that:

@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]});
    }
    return keys;
  }
}

and use it like that:

<span *ngFor="#entry of content | keys">           
  Key: {{entry.key}}, value: {{entry.value}}
</span>

See this question for more details:

  • access key and value of object using *ngFor
Answer from Thierry Templier on Stack Overflow
🌐
Ionic Framework
forum.ionicframework.com › ionic framework › ionic-v3
How to iterate to an array of json objects within the template using *ngFor directive - ionic-v3 - Ionic Forum
January 7, 2018 - Hello guys, I’m new to ionic and I need some help, basically I got my data from the provider as in the following example: Json data: data: { “error”: false, “usrMessage”: “some message”, “internalMessage”: “some internal message”, “additionalInfos”: { “key1”: 9, “key2”: “802.70”, “key3”: 1, “key4”: “151.50”, key5”: 8, “key6”: “651.20” }, “reqDate”: “2018-01-07 18:45:27”, “data”: [ { “dataKey1”: “111”, “dataKey2”: “aaa”, “dataKey3”: “bbb”, “dataKey4”: “ccc”, “dataKey5”: “ddd”...
Discussions

Loop through array of JSON object with *ngFor (Angular 4) - Stack Overflow
My code is working fine but my json-server had some problems. I fixed the problem and now it's finally working. Thanks anyway for your help 2018-01-23T13:26:14.373Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... Stack Overflow chat opening up to all users in January; Stack Exchange chat... Modernizing curation: A proposal for The Workshop and The Archive · 205 How to iterate using ngFor ... More on stackoverflow.com
🌐 stackoverflow.com
January 23, 2018
ngFor with JSON object - Angular 2 ngmodel perspective
I have been trying to do a simple task of taking an input in textbox and listing the same. The sample code is below: Example.html: Name: More on stackoverflow.com
🌐 stackoverflow.com
How to display json object using *ngFor

You might also try out the new (alpha!) angularFire2 lib we're working on: https://github.com/angular/angularfire2, which uses Observables and thus plugs into the async pipe

More on reddit.com
🌐 r/Angular2
4
2
February 28, 2016
How to use *ngFor on a JSON data in Angular? - Stack Overflow
To use *ngFor that object needs to be an array. If it's not an array then you can use a pipe to convert into an array. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › angularjs › how-to-loop-through-array-of-json-object-with-ngfor-in-angular
How to Loop through array of JSON object with *ngFor in Angular ? - GeeksforGeeks
July 23, 2025 - In this article, we will learn How to iterate over these Array of JSON objects/ nested JSON objects using ngFor Directive in Angular. Step 1: Create an Angular application using the following command. ... Step 2: After creating your project folder i.e. appname, move to it using the following command. ... Example 1: In this example, we will iterate through an array of JSON objects and display them in a list. ... <!-- app.component.html --> <h2 style="color: green">GeeksforGeeks</h2> <h2> Loop through array of JSON object with *ngFor </h2> <div *ngFor="let item of gfg "> {{item.name}} <ul> <p *ngFor="let element of item.feature"> <li>{{element.name}} </li> </p> </ul> </div>
🌐
Stack Overflow
stackoverflow.com › questions › 44420880 › how-to-use-ngfor-on-a-json-data-in-angular
How to use *ngFor on a JSON data in Angular? - Stack Overflow
To be clear; by the time it gets to Angular, it's not JSON; it's just JavaScript. JSON is just the string format used to send the data over the wire. ... I observed that in your plunker userDateObj is not array. You need to correct that as · <tr *ngFor="let userDate of userDateObj.userDate">
Find elsewhere
🌐
Reddit
reddit.com › r/angular2 › how to print or display multiple json array using angular ngfor
r/Angular2 on Reddit: How to print or display multiple json array using angular ngFor
November 21, 2017 -

[ { "projectID":"1", "projectname":"project testing", "projectdescription":"

project description proketc description</p>",

"projectimage":"[{"projectimage":"1511182675-0-three13.png"}, {"projectimage":"1511182675-1-two2.png"}]" }, { "projectID":"2", "projectname":"roject settingp", "projectdescription":"

roject setting

", "projectimage":"[{"projectimage":"1511188378-0-three14.png"}, {"projectimage":"1511188378-1-two3.png"}]" }]

I am using angular4 . i want to show above json using ngFor. I used first ngFor *ngFor="let project of projectdata" I tried second ngFor like *ngFor="let projectim of project.projectimage" *ngFor="let projectim of project['projectimage']"

Above is my code I try to print using ngFor. The first ngFor working properly. But the second ngFor shows below error:

Cannot find a differ supporting object '[{"projectimage":"1511188378-0-three14.png"},{"projectimage":"1511188378-1-two3.png"}]' of type 'string'. NgFor only supports binding to Iterables such as Arrays.

🌐
Stack Overflow
stackoverflow.com › questions › 39089097 › using-ngfor-with-a-json-object-in-angular-2
wordpress - Using *ngFor with a JSON object in Angular 2 - Stack Overflow
... Without writing all the code for you, there is no short answer to what you are asking, but here are some tips: You have to take the JSON response you are getting back and create either an interface or class in TypeScript so when you perform ...
Top answer
1 of 4
6

You have gotten some good answers here, but all are manipulating your response and changing the build of it, instead of treating it as is. There is some other data in your response and want to retain the data, so here's a solution using Pipe instead.

You seem to have two objects in your array, but only one contains routes. Will this always be the case? If not, you might want to iterate the response and show all routes (if exists) for all objects, so I'd iterate the array first, and then iterate the routes:

<!-- Iterate array -->
<div *ngFor="let obj of jsonData">
  <!-- iterate routes for each object using pipe -->
  <div *ngFor="let route of obj.routes | keys">
    {{route.toCity}}
  </div>
</div>

And then the keys pipe:

@Pipe({ name: 'keys',  pure: false })
export class KeysPipe implements PipeTransform {
    transform(value: any, args?: any[]): any[] {
      // check if "routes" exists
      if(value) {
        // create instance vars to store keys and final output
        let keyArr: any[] = Object.keys(value),
            dataArr = [];

        // loop through the object,
        // pushing values to the return array
        keyArr.forEach((key: any) => {
            dataArr.push(value[key]);
        });
        // return the resulting array
        return dataArr;
      }
    }
}

This way you have not manipulated your response, and you have access to all other data that is coming with the response.

Demo

2 of 4
1

You will want to convert your object to an iterable array.

  this.http.get('data.json')
            .subscribe((res) => {
               let keyArr: any[] = Object.keys(res.json()[0].routes);
               keyArr.forEach((key: any) => {
                  this.data.push(res.json()[0].routes[key]);
               });
            });

Here's a Plunker

🌐
Stack Overflow
stackoverflow.com › questions › 43025831 › iterating-through-json-object-with-angular-2-ngfor
Iterating through JSON object with Angular 2 ngFor - Stack Overflow
March 26, 2017 - I tried the code below with a simple interface. ... var jsonSample = { "name": "sample1", "content": [ { "id": "3", "name": "Test", "value": "45" }, { "id": "4", "name": "Test2", "value": "60", }] } var items: Array<IContent> = jsonSample.content; ... <tr *ngFor='let content of items'> <td>{{content.name | lowercase}}</td> <td>{{content.id}}</td> <td>{{content.value}}</td> </tr>
🌐
Reddit
reddit.com › r/angular2 › ngfor not working with array of objects deserialized from json
r/Angular2 on Reddit: ngFor not working with array of objects deserialized from json
December 4, 2023 -

Hi,

I have this code below, which correctly deserializes json to an array of my type, but for some reason ngFor thinks it's not in an array and i get a run time error in the console. Project builds fine.

I'm at a loss for why this is happening.

model

export class Month {
  date: string = ""
  metrics: Metrics = new Metrics()
}

export class Metrics {
  wins: number = 0
  losses: number = 0
  draws: number = 0
  averageGameTime: string = ""
  highestRating: number = 0
  lowestRating: number = 0
}

service

  getMonthlyTest() : Month[] {
    var json = JSON.stringify(testMonthlyjson);
    var response = JSON.parse(json) as Month[];
    return response;
  }

code snips from component

    monthlyStats: Month[] = [];


this.service.getMonthlyStats(this.username).subscribe({
    next: (data: Month[]) => {
      console.log("next");
      console.log(data);
      this.monthlyStats = data;
    },
    error: (error: any) => {
      console.log("error");
    },
    complete: () => {
      console.log("comp");
    }
  });
}

html

<div *ngFor="let month of monthlyStats;index as i;">
    <h3>{{month.date}}</h3>
    <h1>{{month.metrics.wins}}</h1>
    <h1>{{month.metrics.losses}}</h1>
    <h1>{{month.metrics.draws}}</h1>
    <h1>{{month.metrics.averageGameTime}}</h1>
    <h1>{{month.metrics.lowestRating}}</h1>
    <h1>{{month.metrics.highestRating}}</h1>
</div>

🌐
Angular Wiki
angularjswiki.com › angular › angular-keyvalue-pipe-loop-object-key-values-using-ngfor
Loop Object Key Values In Angular Using *NgFor & Angular Keyvalue Pipe | Angular Wiki
<p>Loop Through Object using KeyValue Pipe and *ngFor</p> <div *ngFor="let item of object | keyvalue"> {{item | json }} Object Key:{{item.key}} and Object Value:{{item.value}} </div>