how can i loop through json like: { "departments": { "department": {"ID": 1, "Name": "Physics"}, "department": {"ID": 2, "Name": "Chemistry"}, "department": {"ID": 3, "Name": "Biology"} }}
i tried $.each(json.departments.department, function(i, n) { alert(i + " " + n); }); and got ID: 3 Name: Biology but i wanted something like 1: Physics 2: Chemistry 3: Biology