使用jQuery过滤JSON数据? [英] Filter json data using jquery?

查看:98
本文介绍了使用jQuery过滤JSON数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的json数据如下:

My json data looks like this,

{"Table" : [{"accid" : "13","accname" : "Default","accountType" : "Default",
"noOfEmployes" : "","phone" : "","revenue" : "","webSite" : ""},
{"accid" : "15","accname" : "karpagam","accountType" : "Customer",
"noOfEmployes" : "60","phone" : "9894606677","revenue" : "","webSite" : ""},
{"accid" : "14","accname" : "VLB","accountType" : "Customer",
"noOfEmployes" : "60","phone" : "9865636371","revenue" : "","webSite" : ""},
{"accid" : "12","accname" : "XIT","accountType" : "Customer",
  "noOfEmployes" : "20","phone" : "4347980","revenue" : "1000000",
     "webSite" : "xavyinfotech.com"}]}

现在我有一个文本框account name,我的用户可以在其中输入类似任何字符的D,d,kar之类的帐户名,现在我想将该文本与json数据的accname键匹配.我的过滤器可能会产生"n"个结果.是否建议使用jquery过滤json数据?

Now I have a textbox account name where my user can enter an account name like D,d,kar any character and now I want to match that text to my accname keys of my json data. My filter may produce 'n' number of results.. Any suggestion to Filter json data using jquery?

我是否应该依赖其他库(例如 jslinq )?

Should I depend on other libraries like jslinq to do so?

推荐答案

不需要jQuery.

for (el in data.Table) {
  if (somecondition(el.accname) {
    dosomethingwith(el);
  }
}

这篇关于使用jQuery过滤JSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆