Define “cyclic data structures”

前端 未结 9 1970
鱼传尺愫
鱼传尺愫 2021-02-02 09:33

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.

<
9条回答
  •  半阙折子戏
    2021-02-02 10:12

    The object contains a cycle, i.e., it refers to itself or, more generally, some object to which it refers either directly or through some property is the original object.

     var $this =  { };
     $this["self"] = $this;
    

    or more likely

     var child = { parent: null };
     var parent = { child: child };
     child.parent = parent;
    

提交回复
热议问题