Earlz Earlz - 5 months ago 19
JSON Question

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?

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

Now you can do this, for example:

alert(cyclic.somekey.somekey.somekey.another);
Comments