jQuery Loop through JSON Data

Sam Deering
Tweet

jQuery code snippet to loop through JSON data properties. You have an array of objects/maps so the outer loop loops through those. The inner loop loops through the properties on each object element.

Update: Check this post for 5 in depth examples of jQuery.each().

$.each(data, function() {
  $.each(this, function(k, v) {
    /// do stuff
  });
});

Get your free chapter of Level Up Your Web Apps with Go

Get a free chapter of Level Up Your Web Apps with Go, plus updates and exclusive offers from SitePoint.

  • jeff

    Thank you so much. Such a simple piece of life saving code!