Working with json from rails

If we have an array called users which contains a number of User objects sent from our rails app, then looping through this array gives us access to each user object.

for (var i = 0;i<users.length;i++) {
   var user = users[i];
   alert(user.user.name);  //This gives us the name property of the object.
 }

Note that each object in the array is preceeded by the name of the class, hence the double user. syntax.

Leave a Reply