对于JSON对象的操作
增 obj.xxx=‘xxx’
删 delete obj.xxx
改 obj.xxx=‘xxx’
查 obj.xxx
对获取到的数组进⾏简单的操作
模拟获取到后端的数组然后循环输出
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>详细讲解JSON的使⽤</title>
</head>
<body>
<script>
//JSON对象的操作
var obj = {"name":"tim","age":18}
//增
obj.height = "180cm"
//删
delete obj.age
//改
obj.name = "tom"
//查
console.log(obj.name)
//JSON数组进行操作
var arr = [
{"name":"jeck","age":20},
{"name":"maek","age":34},
{"name":"james","age":28}
]
for(var i=0; i<arr.length; i++){
console.log(arr[i])
}
</script>
</body>
</html>
效果图: