// 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. SCCM2012 R2实战系列之七:软件分发(exe)

    在上一章节中,我们完成了SCCM 2012客户端代理软件的安装,现在就可以为客户端来部署应用程序了. SCCM2012增加了应用程序分发,同时保留了SCCM 2007里的包分发.应用程序分发可以直接对 ...

  2. MySQL 分区间进行数据展示 实例

    如何进行分区间数据统计示例 业务场景:统计消费总金额大于1000元的,800到1000元的,500到800元的,以及500元以下的人数. SELECT COUNT(CASE WHEN IFNULL(t ...

  3. c#day01

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace test ...

  4. centos7 使用二进制安装mysql 5.7.23

    1.下载二进制安装包 mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz cd /usr/local/src wget https://cdn.mysql.com// ...

  5. 【Unix网络编程】chapter8基本UDP套接字编程

    chapter8基本UDP套接字编程 8.1 概述 典型的UDP客户端/服务端的函数调用 8.2 recvfrom和sendto函数 #include <sys/socket.h> ssi ...

  6. android Keycode 完全对照表

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

  7. PS添加透明立体水印

    PS: CS2 本文我们介绍用Photoshop为图片添加透明立体水印的方法和技巧. 原图: Duplicate Layer,并输入文字: 设置Layer->Layer Style->Be ...

  8. windows10配置python

    官网下载:https://www.python.org python3---->Download Windows x86-64 executable installer python2----& ...

  9. luogu Eat the Trees

    /* 用和模板类似的方法就行 但是实际上弱化版不用考虑匹配情况限制更加宽松, 只需要保存每个位置有无插头即可, */ #include<cstdio> #include<algori ...

  10. Apache服务器下phalcon项目报Mod-Rewrite is not enabled问题

    问题如图: 项目已经按照官网的教程修改了.htaccess文件,仍旧报此错误,判断可能是apache未添加mod_rewrite,通过查询资料,经以下两步解决此问题: 1.执行sudo a2enmod ...