简体   繁体   English

使用jQuery过滤JSON数据?

[英]Filter json data using jquery?

My json data looks like this, 我的json数据看起来像这样,

{"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"}]}

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. 现在,我有一个文本框account name ,用户可以在其中输入任何字符的D,d,kar类的帐户名,现在我想将该文本与json数据的accname键匹配。 My filter may produce 'n' number of results.. Any suggestion to Filter json data using jquery? 我的过滤器可能会产生“ n”个结果。.关于使用jquery过滤json数据的任何建议?

EDIT: 编辑:

Should I depend on other libraries like jslinq to do so? 我应该依靠jslinq这样的其他库吗?

No need for jQuery. 不需要jQuery。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM