Piyush Piyush - 1 year ago 77
JSON Question

How to iterate JSON array in JavaScript?

I have this below type of array. I want to iterate this array in JavaScript. How is this possible?

var dictionary = {
"images": [

Answer Source

You can do it with the below code. You first get the data array using dictionary.data and assign it to the data variable. After that you can iterate it using a normal for loop. Each row will be a row object in the array.

var data = dictionary.data;

for(var i in data)
     var id = data[i].id;
     var name = data[i].name;

You can follow similar approach to iterate the image array.