ACP
ACP

Reputation: 35264

validating json string using javascript

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.

Upvotes: 0

Views: 188

Answers (1)

Guido
Guido

Reputation: 47685

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");
}

Upvotes: 1

Related Questions