title: Deep filter for values in JSON data
body: <p>I have some JSON data that I am trying to filter based on the checkbox selection of a user in javascript but I have run into a wall as to the multi-level filtering. I have two dimensions of data that need to be filtered from the JSON; first filter the JSON data based on the OS selection, then to filter that resulting OS selection data with a questions selected filter. For example, I am doing the following:</p>
  
  <pre><code>$('.os-checkbox input[type="checkbox"]:checked').each(function() {
      OSSelected.push(Number($(this).parents('.checkbox').index()));
  });
  
  $('.question-checkbox input[type="checkbox"]:checked').each(function() {
      QuestionSelected.push(Number($(this).parents('.checkbox').index()));
  });
  
  var array = $scope.data.responses;
  var osSelectionFilter = array.filter(function(elem, index) {
      return (JSON.stringify(elem.OSSelectedIndex) == JSON.stringify(OSSelected));
  });
  
  console.log(osSelectionFilter); // should return all 'data.response.OSSelectedIndex' objects with the selection made, ex. 0-PC so any selection with "OSSelectedIndex": [0] included
  
  var questionSelectionFilter = osSelectionFilter.filter(function(elem, index) {
      return (JSON.stringify(elem.questionSelectedIndex) == JSON.stringify(QuestionSelected));
  });
  
  console.log(questionSelectionFilter); // should filter the osSelectionFilter above and return all objects with the questions array included, ex. 0, 1, 2...
  </code></pre>
  
  <p>Once a selection is filtered the "result" data in the JSON will populate a div. Issue is now that the filter is trying to filter the whole array I am guessing, e.g. looking for [0, 1] instead of each value in the array individually; where value [0] and [1] are two different separate selections.</p>
  
  <p>JSON data coming from the CMS looks like this:</p>
  
  <pre><code>{
      "id": "test1",
      "fields": {
          "OS": [
              "PC",
              "Mac",
              "Android",
              "iOS"
          ],
          "questions": [{
              "question": "Question 0"
          }, {
              "question": "Question 1"
          }, {
              "question": "Question 2"
          }, {
              "question": "Question 3"
          }, {
              "question": "Question 4"
          }, {
              "question": "Question 5"
          }, {
              "question": "Question 6"
          }],
          "responses": [{
              "ID": 1,
              "OSSelectedIndex": [ 0 ],
              "questionSelectedIndex": [],
              "result": "&lt;h1&gt;Response 1 found&lt;/h1&gt;"
          }, {
              "ID": 2,
              "OSSelectedIndex": [ 0, 1 ],
              "questionSelectedIndex": [ 0, 1, 2 ],
              "result": "&lt;h1&gt;Response 2 found&lt;/h1&gt;"
          }, {
              "ID": 3,
              "OSSelectedIndex": [ 0, 2 ],
              "questionSelectedIndex": [ 0, 1, 2, 5 ],
              "result": "&lt;h1&gt;Response 3 found&lt;/h1&gt;"
          }, {
              "ID": 4,
              "OSSelectedIndex": [ 1, 2 ],
              "questionSelectedIndex": [ 1, 2, 3, 4 ],
              "result": "&lt;h1&gt;Response 4 found&lt;/h1&gt;"
          }]
      }
  }
  </code></pre>
  
  <p>Is such a setup possible?</p>
  
  <p>Plunker with the code above:</p>
  
  <p><a href="https://plnkr.co/edit/N1NJKDOgvVkB9gPmPooi?p=preview" rel="nofollow">https://plnkr.co/edit/N1NJKDOgvVkB9gPmPooi?p=preview</a></p>
  
  <p>Thanks so much</p>