title: v8: Array of objects
body: <p>I'm transforming a parser for v8 in NodeJS. Currently I have the following structure</p>
  
  <pre><code>struct Node {
      short tag;
      std::string data;
  
      Node(std::string input, short tagId) {
          tag = tagId;
          data = input;
      }
  }; 
  
  std::vector&lt;Node&gt; elems;
  </code></pre>
  
  <p>And I'm populating the vector from loop like this:</p>
  
  <pre><code> elems.push_back(Node(STRING, 3));
  </code></pre>
  
  <p>My goal is return a javascript object like this: </p>
  
  <pre><code> [ 
     { tag: 2, data: "asdsad" },
     { tag: 2, data: "asdsad" },
     { tag: 2, data: "asdsad" }
   ]
  </code></pre>
  
  <p>But since the V8 documentation is crappy, I couldn't figure out how to do it. My best shot was to make</p>
  
  <pre><code> Local&lt;Value&gt; data[2] = {
      Local&lt;Value&gt;::New(Integer::New(2)),
      String::New("test")
  };
  </code></pre>
  
  <p>but I can't figure out how to make it an array and return it.</p>
  
  <p>I'm using <a href="https://github.com/kkaefer/node-cpp-modules/blob/master/04_callback_functions/modulename.cpp" rel="nofollow">this example</a> as template.</p>