I'm using a callback to create an object, which I'd like to parse. I'm able to parse the object when the name/value pair I've specified exists, but unable to identify when the name/value pair in my object is undefined.
JSON Object with name/value pair populated:
parseMe([{"item1" : "", "item2" : "", "item3" : [], "item4" : "content goes here"}]);
JSON Object with name/value parsed undefined:
parseMe([{"error" : "Not available"}]);
Parsing logic EX:
var renderR="";
function parseMe(data){
renderR="";
if(data[0].item4!="collapse") renderR=data[0].item4;
//if name/value pair isn't equal to "collapse" render it.
else if(data[0].item4==='undefined'){
document.getElementById('div1').style.display='none';
//if name/value pair is undefined in object hide the div.
}
}