简体   繁体   中英

Filter json data using jquery?

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

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?

EDIT:

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

No need for jQuery.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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