在jsp页面获取后台json数据

后台传过来的是一个JsonArray数组

var a = [{"crtTm":"2013-12-31 11:54:11.0","crtUser":5,"itemDate":"","itemId":2,"itemTm":"1","level":1,"pacId":1,"pacItemId":1,"updTm":"2013-12-31 11:54:11.0","updUser":5},{"crtTm":"2013-12-31 11:54:11.0","crtUser":5,"itemDate":"","itemId":13,"itemTm":"2","level":1,"pacId":1,"pacItemId":2,"updTm":"2013-12-31 11:54:11.0","updUser":5},{"crtTm":"2013-12-31 11:54:11.0","crtUser":5,"itemDate":"","itemId":4,"itemTm":"3","level":0,"pacId":1,"pacItemId":3,"updTm":"2013-12-31 11:54:11.0","updUser":5}]

var b = eval(a);  //转换为对象
alert(b[0].crtTm); //获取第一条数据的crtTm值
alert(b[1].crtTm); //获取第二条数据的crtTm值
alert(b[2].crtTm); //获取第三条数据的crtTm值

相关推荐