# JSON.stringify出现:Converting circular structure to JSON```// Note: cache should not be re-used by repeated calls to JSON.stringify.var cache = [];JSON.stringify(obj, 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; // Enable garbage collection```
JS-JSON
原文地址:https://www.cnblogs.com/jffun-blog/p/10206558.html