ACP
ACP

Reputation: 35268

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?

Upvotes: 0

Views: 6389

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798536

No need for jQuery.

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

Upvotes: 2

Related Questions