title: .grep on an JSON object
body: <p>I'm trying to use grep to filter a Javascript Object like so:</p>
  
  <pre><code>var options = { 
      5: {
          group: "2",
          title: "foo"
      },
      9: {
          group: "1",
          title: "bar"
      }
  };
  
  var groups = $.grep(options, function(e){ return e.group == 2 });
  </code></pre>
  
  <p>I'm getting empty results and I'm guessing it's got something to do with the non-sequential keys of the enclosing object. Any ideas how to fix this?</p>
  
  <h2>Update</h2>
  
  <p>I tried a couple of different grep methods, including using </p>
  
  <pre><code>for (key in option) 
  </code></pre>
  
  <p>to grep on option[key] but I couldn't get his to work. In the end I went a different route as shown here:</p>
  
  <pre><code>var option_ids = new Array();
  for (key in option) {
      if ( option[key]['group'] == 2 ) option_ids.push(option[key]['id']);
  }
  </code></pre>