求jsp json数组遍历方法 50
...teacher{student:[{id:"1234",count:"1"},id:"1235",count:"3"},........]}我有n个学生,学生数目不...
...teacher{
student:[ { id:"1234", count:"1" }, id:"1235", count:"3" },........ ]
}
我有n个学生,学生数目不确定不能写死。怎么执行若干个id 展开
student:[ { id:"1234", count:"1" }, id:"1235", count:"3" },........ ]
}
我有n个学生,学生数目不确定不能写死。怎么执行若干个id 展开
1个回答
展开全部
希望可以帮到你!
<title>利用JavaScript遍历JSON数组</title>
<script type="text/javascript">
function traJsonArray()
{
var jsonArray = [{"id":"100","name":"zhangsan","age":"23","sex":"man"},{"id":"101","name":"lisi","age":"21","sex":"woman"},{"id":"102","name":"wangwu","age":"22","sex":"man"}];
var inputText = "";
for(var json in jsonArray)
{
for(var key in jsonArray[json])
{
inputText += jsonArray[json][key]+",";
}
}
document.getElementById("areaText").innerText = inputText;
}
</script>
</head>
<body>
<div>
<input type="button" id="btn" onclick="traJsonArray()" value="利用JavaScript遍历JSON数组"/>
<textarea id="areaText" cols="80" rows="30"></textarea>
</div>
</body>
<title>利用JavaScript遍历JSON数组</title>
<script type="text/javascript">
function traJsonArray()
{
var jsonArray = [{"id":"100","name":"zhangsan","age":"23","sex":"man"},{"id":"101","name":"lisi","age":"21","sex":"woman"},{"id":"102","name":"wangwu","age":"22","sex":"man"}];
var inputText = "";
for(var json in jsonArray)
{
for(var key in jsonArray[json])
{
inputText += jsonArray[json][key]+",";
}
}
document.getElementById("areaText").innerText = inputText;
}
</script>
</head>
<body>
<div>
<input type="button" id="btn" onclick="traJsonArray()" value="利用JavaScript遍历JSON数组"/>
<textarea id="areaText" cols="80" rows="30"></textarea>
</div>
</body>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询