title: How select all objects within a JSON string with a specific property?
body: <p>I have a string called 'products', with each object having multiple fields, like so:</p>
  
  <pre><code>var prods = JSON.stringify ({"products": [
  
      {
          'prodname': 'Linkedin',
          'oem': 'Linkedin',
          'snippet': 'snippet goes here',
          'linkto': 'http://www.linkedin.com',
          'imagesource': 'resources/images/apps/linkedin.png',
          'category' : 'one'
      },
      {
          'prodname': 'Mozy',
          'oem': 'Mozy',
          'snippet': 'Mozy is the world’s most trusted online backup service for consumers and businesses.',
          'linkto': 'This is the app page links.',
          'imagesource': 'resources/images/apps/mozy.png',
          'category' : 'two'
      },
      {
          'prodname': 'Amazon',
          'oem': 'Amazon',
          'snippet': 'snippet goes here',
          'linkto': 'This is the app page links.',
          'imagesource': 'resources/images/apps/amazon.png',
          'category' : 'one'
      },
  </code></pre>
  
  <p>...and continues in this manner.</p>
  
  <p>I've written a script that will create html elements on the page and populate them with data from the string, creating an app-store type look - which works fine. The problem I have is that I want to only display apps from a certain category at one time, so for instance I want to be able to select all the objects in the string which have a 'category' of 'one'.</p>
  
  <p>As it stands, the part of my code that is selecting the elements looks like this:</p>
  
  <pre><code>var prodobjects = JSON.parse(prods);
  
  function popcatone(){
  
    var catnum =  prodobjects.products.category;
    var numberprods = catnum='one'.length;
  
    var looptimes = 0;
    if (numberprods &gt; 5 &amp; numberprods != 0) {
      looptimes = 5;
    }
    else {
      looptimes = numberprods;
    }
    for (i=0; i &lt; looptimes; i++)
  
    {  //start loop
  
  var imgsrc =  prodobjects.products[i].imagesource;
  var h3text = prodobjects.products[i].prodname;
  var oemtext = prodobjects.products[i].oem;
  var descriptiontext = prodobjects.products[i].snippet;
  var productlink = prodobjects.products[i].linkto;
  </code></pre>
  
  <p>...and then it goes on to distributing the data within html elements. As you can see, the code can currently ascertain how many objects within the string have a 'category' of 'one', and use that to limit the amount of times the code loops if there are less than 5 results, but I simply can't figure out how to actually select the objects with a 'category' of 'one'. As it stands, the code sees the number of results correctly, and indeed renders the correct number of apps onto the page, but the results are simply in a linear order and do not take the category in to account.</p>
  
  <p>I've had a crack at making a fiddle for it but as the css that feeds into it is quite complicated i couldn't get it to represent the behaviour properly. Apologies for the long winded question, and and answers or suggestions will be greatly appreciated.</p>
  
  <p>I'm really not looking for someone to do my work for me, if someone can point me in the right direction on how to select the object based on the value of one of the fields, I'm happy to figure the rest out myself!</p>
  
  <p>Thanks for your patience, and just for the record I'm using jquery 1.10.2</p>