title: Groovy 2 JsonBuilder Nested Iterable Associations
body: <p>I am having 2 issues with the JsonBuilder. I've tried everything I can via researching. This is the closest I have come to solving this but it's not right.</p>
  
  <ol>
  <li>arrays for days and agendas do not feature - they come out as non-arrays.</li>
  <li>Day 2's agendas data is coming out for Day 1's agendas structure for some reason. The underlying data is correct.</li>
  </ol>
  
  <p>Here is the building</p>
  
  <pre><code>def root = builder.output {
      days {
          for (Day day : model.days) {
              "$day.name" { 
                  agendas {
                      for (Agenda agenda : day.agendas) {
                          "$agenda.name" {
                              name agenda.name
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>JSON</p>
  
  <pre><code>{ "output": {
      "days": {
          "Day 1": {
              "agendas": {
                  "Day 2 Agenda B": {
                      "name": "Day 2 Agenda A"
                  },
                  "Day 2 Agenda A": {
                      "name": "Day 2 Agenda A"
                  }
              }
          },
          "Day 2": {
              "agendas": {
                  "Day 2 Agenda B": {
                      "name": "Day 2 Agenda A"
                  },
                  "Day 2 Agenda A": {
                      "name": "Day 2 Agenda A"
                  }
              }
          }
      }
  }}
  </code></pre>
  
  <p>What I am after is:</p>
  
  <pre><code>{ "output": {
      "days": [
          {
              "name": "Day 1",
              "agendas": [
                  {
                      "name": "Day 1 Agenda A"
                  },
                  {
                      "name": "Day 1 Agenda B"
                  }
              ]
          },
          {
              "name": "Day 2",
              "agendas": [
                  {
                      "name": "Day 2 Agenda A"
                  },
                  {
                      "name": "Day 2 Agenda B"
                  }
              ]
          }
      ]
  }}
  </code></pre>