{
"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生成的,我正试图通过jquery访问"months":字符串中的对象,它看起来像一个数组。
我试着像往常一样访问它们,就像在月份一样。
有什么帮助吗?请
感谢
试试jQuery的parseJSON()
函数
类似这样的东西:
var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );
您需要使用month[0].yearText
,因为月份是数组。