let demo = [
'见到你',
{
age: 18
},
'很开心'
]
// 1.利用JSON.stringify() 将js对象序列化成 JSON字符串
console.log(JSON.stringify(demo)) //["见到你",{"age":18},"很开心"]
// 2.再用JSON.parse() 将JSON字符串转化成js对象(反序列化)
console.log(JSON.parse(JSON.stringify(demo))) // ['见到你', {…}, '很开心']
```![](/i/l/?n=23&i=blog/3072329/202302/3072329-20230209181225714-1303558350.png)
标签:开心,stringify,console,demo,parse,JSON
From: https://www.cnblogs.com/orangeczs/p/17106593.html