title: How to fetch a specific object from JSON using JSONPATH by putting the local variable in query string?
body: <p>I am exploring about <a href="https://www.npmjs.com/package/jsonpath" rel="nofollow noreferrer">JSONPATH</a>. And I used it in JS to fetch some specific data from the parent JSON.</p>
  
  <p>Let's say the JSON object that I have is,</p>
  
  <pre><code>var JSON_OBJECT = {
    "data" : [
        {
            "firstname" : "abn",
            "Lastname" : "Bis"
        },
        {
            "firstname" : "abh",
            "Lastname" : "Bis"
        },
        {
            "firstname" : "pqr",
            "Lastname" : "mno"
        }
    ]
  }
  </code></pre>
  
  <p>And I would like to fetch the Objects whose Lastname is "Bis". Then this is my code to fetch those objects.</p>
  
  <pre><code>var fire = require('jsonpath')
  
  var s = "$.data[?(@.Lastname == 'Bis')]"
  
  console.log(fire.query(JSON_OBJECT, s))
  </code></pre>
  
  <p>So my question is if I store "Bis" in a variable. Then how to write the same query to get those objects?</p>
  
  <p>This is what I have tried.</p>
  
  <pre><code>var dataToBeFound = "Bis"
  var s = `$.data[?(@.Lastname == ${dataToBeFound})]`
  console.log(fire.query(JSON_OBJECT, s))
  </code></pre>
  
  <p>This gives me an empty array.</p>