title: Pushing data to JSON object javascript
body: <p>I want to push this object to a JSON array </p>
  
  <pre><code>var obj =  {'x':21,'y':32,'z':43};
  </code></pre>
  
  <p>Since my JSON key:value comes dynamically , I cant access using keys , so i used the loop method . </p>
  
  <pre><code>var str = {xA : []}; //declared a JSON array
  
  for (var key in obj) {
  
      alert(' name=' + key + ' value=' + obj[key]);
  
       str.xA.push({
           key :   obj[key]
       })
  }
  </code></pre>
  
  <p>When i alert the values I am getting the keys and values properly, but when I am pushing it to the array my key is always coming as 'key' instead of the actual key like x, y,z as in the code.</p>
  
  <p>Any help is appreciated.</p>