es5 JSON对象
1. JSON.stringify(obj/arr)
js对象(数组)转换为json对象(数组)
2. JSON.parse(json)
json对象(数组)转换为js对象(数组)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script> "use strict" // 1. JSON.stringify(obj/arr) // //JS对象数组转换为json对象(数组) // 2. JSON.parse(json) // json对象转换为js对象数组 var obj = { usernanme: 'kobe' } obj = JSON.stringify(obj)//json对象 console.log(typeof obj)//string obj = JSON.parse(obj); //js 对象 console.log(typeof obj)//object var a='fddsf' var b="dsdffds" //普通数组 </script> </body> </html>
https://www.cnblogs.com/hack-ing/p/12005296.html 标签:es5,obj,对象,JSON,js,json,数组 From: https://www.cnblogs.com/sunny3158/p/16785665.html