Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define "cyclic data structures"

At the JSON site it says

JSON does not support cyclic data structures, so be careful to not give cyclical structures to the JSON stringifier.

What does it mean by this? Can someone give me an example of such a data structure in Javascript?

like image 531
Earlz Avatar asked Jun 09 '10 22:06

Earlz


1 Answers

var cyclic = {}; cyclic.somekey = cyclic; cyclic.another = "Hello world!"; 

Now you can do this, for example:

alert(cyclic.somekey.somekey.somekey.another); 
like image 118
liori Avatar answered Oct 10 '22 01:10

liori