I am trying to parse a JSON file with the exact stucture as in the following.
{
\"students\": {
\"student\": [
{
\"id
You are not accessing the correct element. data
does not point to students
, it points to the outer most element {students:...}
(students
is an property of it). The array is contained in data.students.student
:
$.each(data.students.student, function() {
//...
});
Further notes:
You don't need to create a local variable if you access a property only once (but of course it might be more readable).
While having consecutive semicolons ;;
is not wrong, it is unnecessary and confusing (at least it confuses me ;))