| 123456789101112131415161718192021222324252627282930313233 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <!-- json 数据格式
- 键名必须是双引号
- 只能是双引 不能是单引号
- 不能注释
- 最后一个属性后面不能加逗号
- json是字符串
- JSON.stringify(js对象转json对象)
- JSON.parse(json对象转js对象)
- -->
- <script>
- let obj1 = {
- name:'你好'
- }
- let obj2 = {
- "name":"家家"
- }
- // console.log(JSON.parse(JSON.stringify(obj1)));
- let obj3 = JSON.stringify(obj1);
- console.log(obj3)
- obj3 = {"name":"你好"};
- // console.log(obj1,'obj1');
- console.log((obj3),'obj3');
- </script>
- </body>
- </html>
|