javascript 解析两层大括号
以下为脱敏后的数据:
this.out_ttt=JSON.stringify([{
"resp": true,
"code": 101,
"time": "2021-08-16 10:13:04",
"data": {
"uuid": "139003d16f7f4559897901372cf5a6a1",
"token": "1e8b41aa89b741afb837386a0de9e7b1",
"updatetime": "2021-08-16 10:13:04",
"endtime": "2021-08-17 10:13:04",
"lastvisit": "1970-01-01 08:00:00"
},
"chk": 11111
}]);
console.log(' methods中的方法 normal_decode中的 out_out ttt '+this.out_ttt);
this.out_rrr=JSON.stringify(this.out_ttt);/////再次对字串进行序列化,数据会带上\"的转义符,但不影响转换 stc ok
console.log(' methods中的方法 normal_decode中的 JSON.stringify out_rrr '+this.out_rrr);
解析:
this.out_tmp= JSON.parse(this.out_out); //////反序列化 stc ok
//////this.out_tmp = this.out_out.parseJSON(); //////反序列化 提示:Error in v-on handler: "TypeError: this.out_out.parseJSON is not a function"
this.uuid=JSON.stringify(this.out_tmp.data.uuid);//////序列化 token
this.yhtoken=JSON.stringify(this.out_tmp.data.token);//////序列化 token
console.log(' methods中的方法 BASE64.decode'+this.out_out);
console.log(' methods中的方法 this.token '+this.yhtoken);
JavaScript中JSON的序列化与反序列化操作解析

本文介绍了在JavaScript中如何使用JSON.stringify()和JSON.parse()进行数据的序列化和反序列化。通过示例展示了如何处理两层大括号的数据,并讨论了在反序列化过程中可能遇到的问题。
500

被折叠的 条评论
为什么被折叠?



