访问数组中的数组 - JSON

时间:2014-05-26 04:45:51

标签: php jquery arrays json

如何在一个json数组中访问该数组。 "

[
  {"series":[
             {"name":"Financial","data":[0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0]}, 
             {"name":"Burial","data":[1,0,1,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0]},
             {"name":"Medical","data":[0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
            ]
  }
]

我想要访问的是"series"的数组

[
 {"name":"Financial","data":[0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0]}, 
 {"name":"Burial","data":[1,0,1,0,0,0,0,1,0,0,2,0,0,0,0,0,0,0,0,0]},
 {"name":"Medical","data":[0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
]

我怎样才能在jquery中这样做?这是我的代码

series1 = JSON.stringify(data[0]);
alert(series1);

我上面提到的是大括号从"series"开始到最后一个大括号。提前致谢。

1 个答案:

答案 0 :(得分:3)

这两种方法都有效:

data[0].series
or
data[0]['series']

并且对于系列内部:

data[0].series[0].name
data[0].series[1].name