开发者

Accessing json output by zendframework with jquery

{
   "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."
}

this json output file was generated by ze开发者_如何学运维ndframework, i am trying to access the objects inside the "months" : string through jquery, which looks like an array.

i have tried to access them like usual objects as in month.yearText with no luck, i am not doing it right of coz.

any help? please.

thanks


Try jQuery's parseJSON() function

Something like this:

var obj = jQuery.parseJSON('{"name":"John"}'); 
alert( obj.name === "John" );


You need to use month[0].yearText, because month is array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜