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

I get a RangeError while serializing a Navigator object.

What could be the reason?

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

Browser: Chrome enter image description here

+8
javascript google-chrome
source share
3 answers

This is because, as the error message says, the navigator object is too large.

You can use the dystroy modified JSON function as follows:

 var navJSON = JSON.pruned(navigator); 

The returned object is quite large, but it is almost certain that it is not entirely correct. If you want to pass data about the navigator object using JSON, you should send only these properties, not the entire object.

+2
source share

Why don't you copy the specific values ​​that interest you for the new object, and then serialize instead?

Perhaps he will find a property that will lead to an infinite loop.

+1
source share

Perhaps the navigator object contains a link. Copy the navigator to another object and delete large links on it.

+1
source share

All Articles