JavaScript - Check if a particular key is available in the JSON
<p>I am retrieving JSON from a live streaming data.
For the first call I am getting dataset array with time and value. But in the second JSON dataset array is empty. I want to check if dataset array contains time key.</p>

<p>Retrieved JSON after first call:         </p>

<pre><code> {
  "activities-heart-intraday": {
    "dataset": [{
        "time": "00:00:00",
        "value": 91
    }, {
        "time": "00:01:00",
        "value": 92
    }, {
        "time": "00:02:00",
        "value": 92
    }],
    "datasetInterval": 1,
    "datasetType": "second"
  }
}
</code></pre>

<p>Retrieved JSON after second call:  </p>

<pre><code>{
  "activities-heart-intraday": {
    "dataset": [],
    "datasetInterval": 1,
    "datasetType": "second"
  }
}
</code></pre>

<p>I am doing</p>

<pre><code>var value = JSON.parse(data);

if (value.hasOwnProperty('time')) {
   console.log("here");
} 
</code></pre>

<p>to check if time key exists in the JSON, but it's not working.</p>

<p>How can I check if a particular key exists in the array in json?</p>