// Demo: Circular reference
var o = {};
o.o = o; // Note: cache should not be re-used by repeated calls to JSON.stringify.
var cache = [];
JSON.stringify(o, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
}
return value;
});
cache = null;

处理TypeError: Converting circular structure to JSON的更多相关文章

  1. 项目中遇到Uncaught TypeError: Converting circular structure to JSON报错问题

    最近公司项目中出现一个报错Uncaught TypeError: Converting circular structure to JSON,,根据上述报错可以知道代码是运行到JSON.stringi ...

  2. Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON

    Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON var obj = { a: &quo ...

  3. Javascript报错Converting circular structure to JSON 错误排解

    在运行nodejs程序的时候报出以下的错误: 2017-11-20 17:44 +08:00: TypeError: Converting circular structure to JSON at ...

  4. JSON.stringify出现 "Converting circular structure to JSON"

    JSON.stringify()  我们很熟悉了,将一个对象转换为json形式的字符串. 但是如果你在浏览器控制台中输出 JSON.stringify(window). 如果期望输出一段文字, 可能会 ...

  5. JSON.stringify方法报错:Converting circular structure to JSON

    别以为JSON.parse(JSON.stringify(data))做深拷贝无敌,对于以下这种情况,当你需要保留父级对象,即 对象存在循环引用,就会报错. var a = [ { "id& ...

  6. Javascript报错Converting circular structure to JSON

    主要是因为对象的互相引用,怎么样才能造成对象的互相引用呢? var a = {}; var b = {}; a.b = b; b.a = a; 怎么解决,反正我试了很多,最后选择深度clone thi ...

  7. python json.dumps raise TypeError(repr(o) + " is not JSON serializable") TypeError: 0 is not JSON serializable

    出错如题. 这个问题有可能是因为python的json.dumps没法识别dump内容里的某些数据类型导致的.我的问题是因为dict中含有numpy.int64,numpy.float等类型导致的,需 ...

  8. [scrapy] exceptions.TypeError:XXX is not json serializable

    原因是spider获取items.py中定义的字段的时候,忘记extract()了 def parseItem(self,response): sel = Selector(response) ite ...

  9. 超越 JSON: Spearal 序列化协议简介

      Spearal 是一个新的开源的序列化协议,这个协议旨在初步替换JSON 将HTML和移动应用连接到Java的后端. Spearal的主要目的是提供一个序列协议,这个协议即使是在端点间传输的复杂的 ...

随机推荐

  1. Linux mysql 5.7.23 主从复制(异步复制)

    docker容器主节点: 172.17.0.9  docker容器子节点: 172.17.0.10 异步复制: 首先确认主库和从库是否一致,最好都是刚刚初始化的干净的数据库 如果主库正在使用不能初始化 ...

  2. 在Docker中安装配置Oracle12c并实现数据持久化

    在Docker中安装配置Oracle12c并实现数据持久化 选定镜像,并pull到系统中,一定要先配置加速,不然超级慢 eric@userver:~$ docker pull sath89/oracl ...

  3. Centos7修改系统时区timezone

    第一步:查询服务器时间 [root@localhost ~]# timedatectl Local time: Sat 2018-03-31 01:11:46 UTC Universal time: ...

  4. C# 将本地文件远程拷贝到其他电脑(转)

    string newpath = System.IO.Path.GetFullPath(@"////10.144.26.252//d$//quyuan//图片" +"// ...

  5. android Keycode 完全对照表

    input keyevent 82 menuinput keyevent 3 homeinput keyevent 19 upinput keyevent 20 downinput keyevent ...

  6. Structrued Streaming业务数据实时分析

    先启动spark-shell,记得启动nc服务 输入以下代码 scala> import org.apache.spark.sql.functions._ import org.apache.s ...

  7. MySQL 中的三中循环 while loop repeat 的基本用法

    -- MySQL中的三中循环 while . loop .repeat 求 1-n 的和 -- 第一种 while 循环 -- 求 1-n 的和 /* while循环语法: while 条件 DO 循 ...

  8. [转]access 标准表达式中数据类型不匹配

    好久没有用access,今儿遇到一个特别让人无语的问题: access数据表的Date/Time类型的字段,假如字段名为dtime: 如果直接用dtime=‘2013/9/6 10:50:21’,sq ...

  9. SikuliI:安装过程(Windows)

    [转载至:http://blog.csdn.net/defectfinder/article/details/49819215] 一.简单介绍 SikuliIDE和Sikuli Script就是现在的 ...

  10. 《算法》第二章部分程序 part 5

    ▶ 书中第二章部分程序,加上自己补充的代码,包括利用优先队列进行多路归并和堆排序 ● 利用优先队列进行多路归并 package package01; import edu.princeton.cs.a ...