练习JSON

 

直接上代码:

index5.html
DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON的实现title>
    <script>
        function loadjsonObjArray() {
            var objs = [{"id":"1","name":"admin","adress":"北京市海淀区","phone":"12312345678"},{"id":"2","name":"梅西","adress":"湖北省武汉市","phone":"12315263748"},{"id":"3","name":"詹姆斯","adress":"四川省成都市","phone":"12313245768"}];

            var trs = "ID姓名地址手机";
            for (var i = 0; i<objs.length;i++){
                trs += ""+objs[i].id+""+objs[i].name+""+objs[i].adress+""+objs[i].phone+"";
            }
            document.getElementById("jsonObjArray").innerHTML = trs;
        }
        function loadjsonArray() {
            var arrays = [{"name":"admin","adress":"北京市海淀区","phone":"12312345678"},{"name":"梅西","adress":"湖北省武汉市","phone":"12315263748"},{"name":"詹姆斯","adress":"四川省成都市","phone":"12313245768"}];
      var select = "";
      document.getElementById("jsonArray").innerHTML = select;

        }
    script>
head>
<body onload="loadjsonObjArray(),loadjsonArray()">
<table id="jsonObjArray"border="1"width="300px"align="center">table>
<div id="jsonArray">div>

body>
html>

实现效果:

练习JSON_第1张图片

 

你可能感兴趣的:(练习JSON)