-
Notifications
You must be signed in to change notification settings - Fork 0
/
Json2
79 lines (63 loc) · 1.37 KB
/
Json2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Json2</title>
</head>
<body>
<p id="demo"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<p id="demo4"></p>
<p id="demo5"></p>
<p id="demo6"></p>
<p id="demo7"></p>
<script>
var myObj, myObj2, myObj3, x, y, z, a, b, c, d="", e, f="";
myObj = { "name":"Github", "alexa":10000, "site":null };
x = myObj.name;
y = myObj["alexa"];
z = myObj.site;
document.getElementById("demo").innerHTML = x;
document.getElementById("demo2").innerHTML = y;
document.getElementById("demo3").innerHTML = z;
for(a in myObj){
document.getElementById("demo4").innerHTML += a + "<br>";
}
for(b in myObj){
document.getElementById("demo5").innerHTML += myObj[b] + "<br>";
}
myObj2 = {
"name":"partice",
"number":"100000",
"webs":{
"web1":"www.google.com",
"web2":"www.github.com",
"web3":"www.chainstack.com"
}
}
myObj2.webs["web0"] = " www.pulumi.com";
<!-- pulumi只能在web4加入,web0是undefined无法修改 -->
myObj2.webs.web1="www.google.com";
for(c in myObj2.webs){
d += myObj2.webs[c]+ "<br>";
}
document.getElementById("demo6").innerHTML = d;
myObj3 = {
"name":"partice",
"number":"100000",
"webs":{
"web1":"www",
"web2":"gmail",
"web3":"com"
}
}
delete myObj3.webs["web1"];
for(e in myObj3.webs){
f += myObj3.webs[e] + "<br>";
}
document.getElementById("demo7").innerHTML = f;
</script>
</body>
</html>