title: How to loop through & add pairs of values to JSON object?
body: <p>Using the <a href="https://github.com/claviska/jQuery-SelectBox" rel="nofollow">jQuery SelectBox plugin</a> I'm trying to create a JSON object which looks as follows, where <code>'value'</code> and <code>'name'</code> are pairs of values for a select box:</p>
  
  <pre><code>'Opt Group 1': {
      'value': 'name',
      'value': 'name',
      'value': 'name',
      'value': 'name',
      'value': 'name'
  },
  </code></pre>
  
  <p>So that when I loop through my data, I push more data to the end of the array. Currently, to display the <code>'name'</code> only, I use the following:</p>
  
  <pre><code>var jsonObj = [];
  for(var i=0; i&lt;data.length; i++){
      jsonObj.push(data[i].name);
  }
  console.log(jsonObj);
  </code></pre>
  
  <p>So far as I understand it, JavaScript doesn't seem to like using variables as identifiers, i.e. I can't do: <code>jsonObj.push({data[i].id:data[i].name});</code></p>
  
  <p>How might I go about creating the kind of JSON object I need, in order to get the Select Box working as needed?</p>