最近用到这种数据格式,收集了一些文档及资料,以及用.NET生成JSON数据前台绑定用

 

JSON.NET 3.5:Json35b2.zip

JSON.NET 1.3.1:Json131.zip

文档:JSON.doc.rar

 

PS:将字符串转换为JSON对象,用JS的EVAL方法[红色部分需要注意添加]

var tempdata = document.getElementById("Label").innerText;
var data = eval("("+tempdata+")");

有一个疑问:

如何筛选JSON数据???

 

 1 //想要得到tom女儿lucy的信息怎么办?
 2 
 3 
 4   var data= { 
 5                "name":"mike",
 6                "age":62,
 7                "children":[
 8                         {
 9                             "name":"tom",
10                             "age":28,
11                             "children":[
12                                     {
13                                         "name":"nick",
14                                         "age":4,
15                                         "children":null
16                                     },
17                                     {
18                                         "name":"lucy",
19                                         "age":6,
20                                         "children":null
21                                     }
22                                 ]
23                         },
24                         {
25                             "name":"jerry",
26                             "age":24,
27                             "children":null
28                         }
29                    ]
30             }
31 
32 

 

使用  data.children[0].children[0].name

可以得到结果,但是可以筛选吗?

像XML的  data.children[@name="tom"].children[0]

 

  .

posted on 2009-02-20 11:30  xiaohc  阅读(470)  评论(0编辑  收藏  举报