Javascript - JSON.stringify - Circular Structure

    let cache = [];
    let result = JSON.stringify(pool.pool, (key, value) => {
        if (typeof value === 'object' && value !== null) {
            // Duplicate reference found, discard key
            if (cache.includes(value)) return;
            // Store value in our collection
            cache.push(value);
        }
        return value;
    });
    cache = null;

 

你可能感兴趣的:(Javascript)