title: How to assign values to JSON object
body: <p>I have the following code that does not work.  I am trying to push the text "John" onto the end of the object.  I am more familiar with PHP, and this works in PHP. </p>
  
  <pre><code>var data = {};
  var field_name = "first_name";
  
  data[field_name]['answers'][] = "John";
  
  alert(data['first_name']['answers'][0]);
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>I also tried the following and it did not work.</p>
  
  <pre><code>var data = {};
  var field_name = "first_name";
  var i=0;
  
  data[field_name]['answers'][i] = "John";
  
  alert(data['first_name']['answers'][0]);
  </code></pre>