2010-08-16 40 views
0

我有这个json字符串{"Table" : [{"subject" : "No Records are there to Display"}]}。 如果我收到此数据,我想提醒NO Records Found。任何建议。使用javascript验证json字符串

注:我的键字段可以相应地改变(即)这里是Subject有的更像DetailsDescription

回答

1

我会使用jquery或任何其他库的JSON字符串转换成JS对象:

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

井obj.Table是JSON字典的阵列。不应该这样做obj.Table [0] .subject ===“没有记录显示”? – 2010-08-16 06:52:59

+0

是的,你是对的。固定。 – 2010-08-16 15:04:10