title: Problems with creating an array of structs
body: <p>I'm making a blog API and am having some very strange issues when trying to create an array of structs in coldfusion. The top level array will contain the post, as a struct, with a .comments that is an array of all comments under that post, also as structs.</p>
  
  <p>Each of the pieces in the following code work individually. But, somehow when I put them together I end up with an infinitely nested array of structs containing an array of structs etc... all of only the very last element in the top level array of posts.</p>
  
  <pre><code>&lt;cfset posts = VARIABLES.postDao.getBlogPosts(argumentCollection=arguments) /&gt;
  &lt;cfset result = arraynew(1) /&gt;
  
  &lt;cfloop index="i" from="1" to="#arrayLen(posts)#"&gt;
    &lt;cfset post = posts[i].getInstance()&gt;
    &lt;cfset StructInsert(post, 'comments', getComments(post.postId))&gt;
    &lt;cfset ArrayAppend(result, post)&gt;
  &lt;/cfloop&gt;
  </code></pre>
  
  <p>getBlogPosts returns an array of Post beans.<br>
  bean.getInstance() returns a struct with all the data in the bean.<br>
  getComments(id) returns an array all comments(structs) for post[id].</p>
  
  <p>Each of these works as intended and is used elsewhere without problems.</p>
  
  <p>The structure of the infinitely nested array is as such:  </p>
  
  <pre><code>Array containing Post  
  .  Post.comments containing array of comments + Post on end  
  .  .  Post.comments containing array of comments + Post on end
  .  .  . etc...
  </code></pre>