{
"code":100,
"data":{
"month":[
{
"yearText":"2011",
"months":[
{
"monthText":"6",
"days":[
{
"dayText":"13",
"cios":[
{
"status":"continues",
"start":"23:00:00",
"end":"23:59:59",
"id":12
}
],
"bois":[
{
"status":"continues",
"start":"23:30:00",
"end":"23:59:59",
"id":12
}
]
},
{
"dayText":"14",
"cios":[
{
"status":"continued",
"start":"00:00:00",
"end":"01:00:00",
"id":12
},
{
"status":"within",
"start":"11:42:14",
"end":"11:43:45",
"id":11
}
],
"bois":[
{
"status":"continued",
"start":"00:00:00",
"end":"00:30:00",
"id":12
},
{
"status":"within",
"start":"11:42:39",
"end":"11:43:33",
"id":11
}
]
}
]
}
]
}
],
"next":"\/attendance\/get-history\/2011\/07",
"previous":"\/attendance\/get-history\/2011\/05"
},
"msg":"Attendance history of John Doe on June, 2011."
}
这个json输出文件是由zendframework生成的,我试图访问“months”中的对象:字符串通过jquery,看起来像一个数组。
我试图像普通对象一样访问它们,就像在month.yearText中没有运气一样,我没有做到这一点。
任何帮助?请。
感谢
答案 0 :(得分:0)
您需要使用month[0].yearText
,因为月份是数组。
答案 1 :(得分:0)
尝试jQuery的parseJSON()
函数
这样的事情:
var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );