I have a sample JSON
file:
{
"array": [
1,
2,
3
],
"boolean": true,
"null": null,
"number": 123,
"object": {
"a": "b",
"c": "d",
"e": "f"
},
"string": "Hello World"
}
I need to get object from array
.
Everything work but I want to show alert that there is no "4" in that object
Tried something like that:
if(check == null){
alert("not exist")
}
But its not working. I tried also put undefined instead of null but it is not working as well. What should i put there ?
Rest this are working fine. I know how to get data from JSON
. The only issue is that check function.
$.getJSON(host_address ,function(data){
var check = data.array[4]
if(check == null){
alert("not exist")
}
});