How to loop through a JSON object with typescript (Angular2)

The Solution to How to loop through a JSON object with typescript (Angular2) is


Assuming your json object from your GET request looks like the one you posted above simply do:

let list: string[] = [];

json.Results.forEach(element => {
    list.push(element.Id);
});

Or am I missing something that prevents you from doing it this way?

~ Answered on 2017-05-01 20:50:47


Most Viewed Questions: