title: How to create a JSON array in JQuery?
body: <p>I want to create a JSON array like this:</p>
  
  <pre><code>var ddBasic = [
      { text: "Facebook", value: 1, },
      { text: "Twitter", value: 2, },
      { text: "LinkedIn", value: 3, },
      { text: "Foursquare", value: 4, }
  ];
  </code></pre>
  
  <p>I'm using data from last.fm, so it would be something like this:</p>
  
  <pre><code>var tags = [
          { text: "rock", value: "rock", },
          { text: "pop", value: "pop", },
      ];
  </code></pre>
  
  <p>It needs to have a comma at the end so the <a href="http://designwithpc.com/Plugins/ddSlick#demo" rel="nofollow">ddslick</a> dropdown function ignores the imageSrc and other things it can use for a dropdown, other it throws this error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'imageSrc' of undefined
  </code></pre>
  
  <p>To tie everything together, I have:</p>
  
  <pre><code>$('#tag').ddslick({
      data: tags,
      onSelected: function(selectedData) {}   
  });
  </code></pre>
  
  <p>This is the function that gets the tags:</p>
  
  <pre><code>var tags = [];
  
  var getTopTracks = function () {
      $.getJSON(
      settings.PHP_REQUEST_URL, {
          method: "tag.getTopTags",
          api_key: settings.LASTFM_APIKEY,
          format: "json",
      },
  
      function (data) {
          var limit = 50;
  
          data.toptags.tag.sort(function (t1, t2) {
              return t2.count - t1.count;
          });
  
          $.each(data.toptags.tag, function (i, item) {
              if (i &gt; limit) return false;
              console.log(item.name);
              tags.push({
                  text: item.name,
                  value: item.name
              });
          });
      });
  };
  
  // event handlers (load quando o form é invocado só)
  getTopTracks();
  alert(tags.length);
  
  // define tema para a combobox   
  $('#tag').ddslick({
      data: tags,
      onSelected: function (selectedData) {}
  });
  </code></pre>
  
  <p>How can I accomplish this?</p>