title: iterating over JSON object in ejs partial
body: <p>I am trying to loop over each entry in "default", in my JSON file below, within an EJS partial. </p>
  
  <pre><code>{
      "default": {
          "1": {
              "id": "alertmessages",
              "title": "Your Messages",
              "subtitle": "Tasks waiting for your attention",
              "image": "alert.png",
          },
          "2": {
              "id": "uploadr",
              "title": "Upload",
              "subtitle": "Upload",
              "image": "baskets.png",
          },
          etc............
      }
  }
  </code></pre>
  
  <p>I am reading this JSON file into my node.js, parsing it and making it available for my dashboard view. as below</p>
  
  <pre><code>var jsondata = JSON.parse(require('fs').readFileSync('./app/routes/dashboard/buttons.json', 'utf8'));
  
  var content = {
      title: 'Dashboard',
      user: req.user,
      buttonsdata: jsondata
  };
  res.render('dashboard', content);
  </code></pre>
  
  <p>My dashboard view, includes an ejs partial in which I am trying to loop over all the objects contained within default (this number may vary). I want to do this without Jquery. But having trouble getting any of the suggestions working that I have found on other threads.</p>
  
  <pre><code>console.log("&lt;%= buttonsdata.default.[1].id %&gt;")
  </code></pre>
  
  <p>gives me what I would expect, however if i try and console log <strong>buttons.length</strong>, which is used in loop examples I have seen, it just comes up blank.
  also how can I console log the entire contents of the object to see its structure?
  thirdly - this object, in this manner as I can tell is available through ejs, however not to core javascript and i can only access it using the ejs &lt;% %> tags. is this a correct understanding?</p>