javascript JSON.stringify(navigator) 期间超出了最大调用堆栈大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14290620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 21:14:47  来源:igfitidea点击:

Maximum call stack size exceeded during JSON.stringify(navigator)

javascriptgoogle-chrome

提问by P K

I am getting RangeError during serialization of Navigator object.

我在 Navigator 对象的序列化期间收到 RangeError。

What could be the reason?

可能是什么原因?

JSON.stringify(navigator);
RangeError: Maximum call stack size exceeded

Browser: Chrome enter image description here

浏览器:Chrome 在此处输入图片说明

采纳答案by Some Guy

That's because, as the error message says, the navigatorobject is too big.

那是因为,正如错误消息所说,navigator对象太大了。

You can use dystroy's modified JSON functionlike this:

您可以像这样使用dystroy的修改后的JSON函数

var navJSON = JSON.pruned(navigator);

The object returned is pretty huge, but it's almost certain that it isn't completely correct. If you want to transfer data about the navigatorobject using JSON, you shouldsend those properties only, not the entire object.

返回的对象非常大,但几乎可以肯定它不完全正确。如果要navigator使用 JSON传输有关对象的数据,则应仅发送这些属性,而不是整个对象。

回答by Michael Christensen

Why dont you copy the specific values you are interested over to a new object and then serialize that instead?

为什么不将感兴趣的特定值复制到新对象中,然后对其进行序列化?

Maybe its finding a property that results in an endless loop.

也许它找到了一个导致无限循环的属性。

回答by mr0re1

Maybe navigator object contain the self-link. You should copy navigator in other object and delete big links on them.

也许导航器对象包含自链接。您应该在其他对象中复制导航器并删除它们上的大链接。