views:

27

answers:

1

I have this json string {"Table" : [{"subject" : "No Records are there to Display"}]}. If i receive this data i want to alert NO Records Found. Any suggestion.

Note: My key field may vary accordingly (ie) here it is Subject and some more like Details,Description.

+1  A: 

I'd use jquery or any other library to convert the JSON string into a JS object:

var obj = jQuery.parseJSON('{"Table" : [{"subject" : "No Records are there to Display"}]}');
if (obj.Table[0].subject === "No Records are there to Display") {
    alert("NO Records Found");
}
Guido
well the obj.Table is an array of json dictionary. Shouldn't this be as obj.Table[0].subject === "No Records are there to Display" ?
anand
Yes, you are right. Fixed.
Guido