nodejs 循环引用JSON序列化错误的解决办法:TypeError: Converting circular structure to JSON

2017-07-16 20:19:41

nodejs 循环引用JSON序列化错误的解决办法:TypeError: Converting circular structure to JSON

可以 使用 util.inspect 代替 JSON.stringify

var util = require("util")var a = {};
a.b = a;
a.c = "123"; 
// console.log(JSON.stringify(a)); // 报错console.log(util.inspect(a,{depth:null})); //depth:null 展开全部层级12345671234567

如上代码输出结果

{ b: [Circular], c: '123' }


  • 2019-07-10 18:02:28

    Centos7安装percona-xtrabackup2.4和8.0版本

    Percona XtraBackup是一个基于MySQL的服务器的开源热备份实用程序 ,它不会在备份期间锁定您的数据库。 无论是24x7高负载服务器还是低事务量环境,Percona XtraBackup都旨在使备份成为一个无缝过程,而不会破坏生产环境中服务器的性能。

  • 2019-07-11 11:35:20

    VirtualBox添加新硬盘

    昨晚在自己的virtualbox中的linux装matlab2010a,没想到硬盘空间不足,所以找了下怎么添加硬盘的资料。也很简单,每几条命令。 大致流程:我的virtualbox版本是3.2.8,linux版本是xubuntu10.01吧貌似