Concepts

Circular JSON limitation

Try the free JavaScript compiler

Ordinary JSON serialization throws TypeError when a traversed object is already on the active serialization path. Shared noncyclic references can serialize twice.

Formal Syntax & Structure

javascript syntaxjavascript
JSON.stringify(cyclicObject)

Working Example

Example Snippetjavascript
const x={};x.self=x;try{JSON.stringify(x);}catch(e){console.log(e.name);}
JavaScript Reference