looping through a nested json object javascript

Subject:

object {success:true, distribution: object}

  • distribution:object
    • customers:array[2]
      • 0:object
        • created:0000-00-00
        • customerID:45
        • etc...
      • 1:object
        • created:0000-00-00
        • customerID:45
        • etc...
    • users:array[1]
      • 0:object
        • created:0000-00-00
        • customerID:45
        • etc...

the above nested object, since its already an object you don't use JSON.parse or anything you simple find a way to loop through.  Simple un-nested object $.each() in jQuery will do the trick.  In this example I used a for loop for it.

       for(var i =0; i < data.distribution.customers.length; i++){                                         if(data.distribution.customers[i].field == 'to'){                     console.log(data.distribution.customers[i]);                 }         }

2016-09-23 09:49:51gstlouis

                        for(var i =0; i < data.distribution.customers.length; i++){
                            
                            if(data.distribution.customers[i].field == 'to'){
                                console.log(data.distribution.customers[i]);    
                            }
                        }

gstlouis
vote
2016-09-23 09:49:59