遍历json集合
[{"list":[{"count":0,"createTime":"2008-01-2500:00:00","createUserDept":"","createUse...
[{"list":[{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":"","createUserId":"","createUserName":"","deleteFlag":"0","introduction":"","month":"","pagerSize":0,"periodicalId":"","periodicalName":"admin","periodicalType":"","publishDate":null,"status":"0","updateUserDept":"","updateUserDeptId":"","updateUserId":"","updateUserName":"","year":""},{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":"","createUserId":"","createUserName":"","deleteFlag":"0","introduction":"","month":"","pagerSize":0,"periodicalId":"","periodicalName":"admin","periodicalType":"","publishDate":null,"status":"0","updateUserDept":"","updateUserDeptId":"","updateUserId":"","updateUserName":"","year":""}],"pageString":""}]
可追加分,如何遍历上面json对象 展开
可追加分,如何遍历上面json对象 展开
展开全部
var a=[{"list":[{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":"","createUserId":"","createUserName":"","deleteFlag":"0","introduction":"","month":"","pagerSize":0,"periodicalId":"","periodicalName":"admin","periodicalType":"","publishDate":null,"status":"0","updateUserDept":"","updateUserDeptId":"","updateUserId":"","updateUserName":"","year":""},{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":"","createUserId":"","createUserName":"","deleteFlag":"0","introduction":"","month":"","pagerSize":0,"periodicalId":"","periodicalName":"admin","periodicalType":"","publishDate":null,"status":"0","updateUserDept":"","updateUserDeptId":"","updateUserId":"","updateUserName":"","year":""}],"pageString":""}]
var list=a[0].list;
for(i=0;i<list.length;i++){
alert(list[i].count);
alert(list[i].createTime);
............
............
............
}
当数组处理,只是成员为对象
var list=a[0].list;
for(i=0;i<list.length;i++){
alert(list[i].count);
alert(list[i].createTime);
............
............
............
}
当数组处理,只是成员为对象
追问
你好:那我从后台返回到页面的值还可以是json对象吗
追答
可以的,你在转到前台过程中 进行stringbuff拼接,到前台 JS遍历一样;
过程只是字符串的传递;
展开全部
list中包含一个数组,在那对中括号里每对大括号包裹的就是数组中的一个元素,楼主可以将这个json字符串理解为有两个节点,第一个是list(内容是数组),第二个是pageString
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
var json={
"list":[
{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":""},
{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":""}
],
"pageString":""
};
//traverse
for (var key in json)
{
for (var option in json[key])
{
document.write(json[key][i].count);
}
}
"list":[
{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":""},
{"count":0,"createTime":"2008-01-25 00:00:00","createUserDept":"","createUserDeptId":""}
],
"pageString":""
};
//traverse
for (var key in json)
{
for (var option in json[key])
{
document.write(json[key][i].count);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-07-09
展开全部
。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询