<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>02_JSON对象</title>
</head>
<body>
<!--
1. JSON.stringify(obj/arr)
* js对象(数组)转换为json对象(数组) 【json对象(数组);字符串类型】
2. JSON.parse(json)
* json对象(数组)转换为js对象(数组)
-->
<script type="text/javascript">
var obj = {
name: 'kobe',
age: 39
};
obj = JSON.stringify(obj);
console.log(typeof obj); // string
console.log(obj); // {"name":"kobe","age":39}
obj = JSON.parse(obj);
console.log(typeof obj); // object
console.log(obj); // {name: "kobe", age: 39}
</script>
</body>
</html>