2010-09-02 58 views
0

我的JSON数据是这样的,使用jquery过滤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"}]} 

现在我有一个文本框account name在我的用户可以输入帐户名状D,d,kar任何字符,现在我想的文本匹配我的json数据accname键。我的过滤器可能会产生'n'个结果..任何建议使用jQuery过滤json数据?

编辑:

我应该依赖于其他图书馆一样jslinq这样做呢?

回答

2

不需要jQuery。

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

@Ignacio会删除过滤器中的所有其他行吗? – 2010-09-02 05:39:35

+0

不会。它只会遍历行并允许您处理您感兴趣的行。 – 2010-09-02 05:43:45

+0

@Ignacio我认为您误解了我的问题...我想过滤掉我的json对象而无需迭代它... – 2010-09-02 05:51:19