使用 javascript 验证 json 字符串

发布于 2024-09-14 03:59:22 字数 251 浏览 1 评论 0原文

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

注意:我的关键字段可能会相应变化(即,这里是主题,还有一些类似详细信息描述

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-09-21 03:59:23

我会使用 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");
}

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");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文