title: Adding elements to object
body: <p>I need to populate a json file, now I have something like this:</p>
  
  <pre><code>{"element":{"id":10,"quantity":1}}
  </code></pre>
  
  <p>And I need to add another "element". My first step is putting that json in a Object type using <code>cart = JSON.parse</code>, now I need to add the new element.
  I supposed I must use <code>cart.push</code> to add another element, I tried this:</p>
  
  <pre><code>var element = {};
  element.push({ id: id, quantity: quantity });
  cart.push(element);
  </code></pre>
  
  <p>But I got error "Object has no method push" when I try to do <code>element.push</code>, and I think I'm doing something VERY wrong because I'm not telling the "element" anywhere.</p>
  
  <p>How can I do that?</p>
  
  <p><strong>Edit:</strong> sorry to all I had a LOT of confusion in my head.</p>
  
  <p>I thought I can get only object type when taking data from <code>JSON.parse</code>, but I get what I put in the JSON in the first place.</p>
  
  <p>Putting array instead of object solved my problem, I used lots of suggestions got here too, thank you all!</p>