处理TypeError: Converting circular structure to JSON
// 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的更多相关文章
- 项目中遇到Uncaught TypeError: Converting circular structure to JSON报错问题
最近公司项目中出现一个报错Uncaught TypeError: Converting circular structure to JSON,,根据上述报错可以知道代码是运行到JSON.stringi ...
- Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON
Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON var obj = { a: &quo ...
- Javascript报错Converting circular structure to JSON 错误排解
在运行nodejs程序的时候报出以下的错误: 2017-11-20 17:44 +08:00: TypeError: Converting circular structure to JSON at ...
- JSON.stringify出现 "Converting circular structure to JSON"
JSON.stringify() 我们很熟悉了,将一个对象转换为json形式的字符串. 但是如果你在浏览器控制台中输出 JSON.stringify(window). 如果期望输出一段文字, 可能会 ...
- JSON.stringify方法报错:Converting circular structure to JSON
别以为JSON.parse(JSON.stringify(data))做深拷贝无敌,对于以下这种情况,当你需要保留父级对象,即 对象存在循环引用,就会报错. var a = [ { "id& ...
- Javascript报错Converting circular structure to JSON
主要是因为对象的互相引用,怎么样才能造成对象的互相引用呢? var a = {}; var b = {}; a.b = b; b.a = a; 怎么解决,反正我试了很多,最后选择深度clone thi ...
- 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等类型导致的,需 ...
- [scrapy] exceptions.TypeError:XXX is not json serializable
原因是spider获取items.py中定义的字段的时候,忘记extract()了 def parseItem(self,response): sel = Selector(response) ite ...
- 超越 JSON: Spearal 序列化协议简介
Spearal 是一个新的开源的序列化协议,这个协议旨在初步替换JSON 将HTML和移动应用连接到Java的后端. Spearal的主要目的是提供一个序列协议,这个协议即使是在端点间传输的复杂的 ...
随机推荐
- 文件上传(asp.net webform中)
1.配置允许上传文件大小 <configuration> <appSettings> <!--配置上传文件最大字节数:单位KB--> <add key=&qu ...
- Redis-Migrate-Tool 使用详解
注意:目前不支持4.0.X及以上的redis使用 Redis 集群迁移工具,基于redis复制,快速,稳定. github链接:https://github.com/vipshop/redis-mig ...
- XML与 实体的相互转化
using System; using System.Linq; using System.Xml; using System.Reflection; using System.Data; using ...
- cocos源码分析--绘制顺序LocalZOrder、GlobalZOrder、OrderOfArrival
使用规则 节点的渲染顺序跟节点的三个成员变量有关(_localZOrder._globalZOrder._orderOfArrival)分别对应三个设置函数setLocalZOrder.setGlob ...
- Install and Configure Apache Kafka
I. Installation The installation environment must have JDK, verify that you enter: java -version 1. ...
- C#提取双引号中的字符串
public static void Main(string[] args) { string strtmp = "123\"456\"qqq\"789\&qu ...
- express总结(一)
Express 框架核心特性: 可以设置中间件来响应 HTTP 请求. 定义了路由表用于执行不同的 HTTP 请求动作. 可以通过向模板传递参数来动态渲染 HTML 页面. express保留了Nod ...
- EXCEL workbook.saveas 函数详解
本问所有资料来自于 Excel2003 VBA帮助文件,张荣整理,适用于DELPHI,VB的高级语言操作Excel用 ExcelApplication.WorkBook.SaveAs(filename ...
- replace 使用正则
python replace正则怎么用 20 下面是我的代码:s="今天是2015年10月1日国庆节,明天是2015年10月2日"s=s.replace(r'[0-9]*', '0 ...
- Java编辑PDF写入文字 插入图片
package com.test; import com.itextpdf.text.BaseColor; import com.itextpdf.text.Font; import com.itex ...