title: How to filter json based on a query dynamically generated?
body: <p>I want to filter a json object using js for an angular project.
  The Json structure would be like this:</p>
  
  <pre><code>{
   "docs": [
  {
    "Firstname": "",
    "Lastname": "",
    "Birthdate": "",
    "city": "",
    "country": ""
  },
  {
    "Firstname": "",
    "Lastname": "",
    "Birthdate": "",
    "city": "",
    "country": ""
  }
  ]
  }
  </code></pre>
  
  <p>the query builder is similar to <a href="http://mfauveau.github.io/angular-query-builder/" rel="nofollow noreferrer">angular-query-builder</a></p>
  
  <p>A Sample query that could be generated using the query builder would be something like as follows:</p>
  
  <pre><code>(Firstname = tom OR (Firstname = jerry AND Lastname = jack))
  </code></pre>
  
  <p>based on this query a Js function should filter the json object and console the resulting json .</p>
  
  <p>Have seen custom functions for filtering, but don't know how to create a dynamic filtering function based on the query being generated.</p>