title: Check if a key exists inside a JSON object
body: <pre><code>amt: &quot;10.00&quot;
  email: &quot;sam@gmail.com&quot;
  merchant_id: &quot;sam&quot;
  mobileNo: &quot;9874563210&quot;
  orderID: &quot;123456&quot;
  passkey: &quot;1234&quot;
  </code></pre>
  <p>The above is the JSON object I'm dealing with. I want to check if the <code>merchant_id</code> key exists. I tried the below code, but it's not working. Any way to achieve it?</p>
  <pre><code>&lt;script&gt;
  window.onload = function getApp()
  {
    var thisSession = JSON.parse('&lt;?php echo json_encode($_POST); ?&gt;');
    //console.log(thisSession);
    if (!(&quot;merchant_id&quot; in thisSession)==0)
    {
      // do nothing.
    }
    else 
    {
      alert(&quot;yeah&quot;);
    }
  }
  &lt;/script&gt;
  </code></pre>