This article mainly shares with you part of the code about js parsing json array objects into two-dimensional arrays. I hope it can be helpful to friends in need
The key codes are as follows:
<script type="text/javascript">function zh(data)//用户将json数组对象解析成二维数组 { var arr = []; for(var i in data) { arr[i] = []; for(var j in data[i]) { arr[i].push(data[i][j]); } } return arr; } function addTable(getdata) {//将解析出来的二维数组显示 var p1=document.getElementById("p1"); var tab="<table border='1' width='200' >"; var arr =[]; arr = zh(getdata); for(var i =0;i<arr.length;i++) { tab+="<tr>"; for(var j = 0;j<arr[i].length;j++) { tab+="<td>"+ arr[i][j] +"</td>"; } tab+="</tr>"; } tab+="</table>"; p1.innerHTML=tab; }
</script> 相关推荐:
<a href="http://www.php.cn/js-tutorial-388752.html" target="_self">nodejs解析xml字符串为对象的实例</a><br><br>
The above is the detailed content of js parses json array object into two-dimensional array. For more information, please follow other related articles on the PHP Chinese website!