如何解决'未捕获TypeError:将循环结构转换为JSON' [英] How to solve ' Uncaught TypeError: Converting circular structure to JSON '

查看:694
本文介绍了如何解决'未捕获TypeError:将循环结构转换为JSON'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行一个网页,但在控制台上检查时显示以下错误。
'未捕获TypeError:将循环结构转换为JSON'

Im executing a webpage but it displaying following error while checking it on Console. 'Uncaught TypeError: Converting circular structure to JSON'

console.log(JSON.stringify(physicianInfo));
 Ext.Ajax.request(
   { async : true, 
     url : Global.URLPrefix + 'addPhysicianInformation', 
     method : 'GET', 
     params : { 
         physicianInfo : JSON.stringify(physicianInfo), callFrom : 'add' },
     success : function (request, resp) { 
         var physician1 = Ext.decode(request.responseText); console.log(physician1);


推荐答案

对象之间的循环引用。

例如:

A references B
B references A

当您尝试并序列化A时,需要将B序列化,但是它需要再次序列化A,并且没有办法在JSON中表示该循环,结果将是无限递归循环。

When you try and serialize A then it needs to serialize B, but then it needs to serialize A again and there is no way to represent that loop in JSON. The result would be an infinite recursive loop.

您需要识别和删除请记住,链条可能比上述更复杂:

You need to identify and remove the circular references. Remember that the chain can be more complex than the above:

A references B
B references C
C references A

有多少个链接或它们如何存储无关紧要。如果您可以从一个对象转到另一个对象,然后通过任何路由返回到第一个对象,那么它是一个循环引用。

It doesn't matter how many links there are or how they are stored. If you can go from one object to another object and then back to the first one by any route then it is a circular reference.

这篇关于如何解决'未捕获TypeError:将循环结构转换为JSON'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆