Define “cyclic data structures”

前端 未结 9 1816
鱼传尺愫
鱼传尺愫 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 09:58

    js> var a = {label:"a", next:null};
    js> var b = {label:"b", next:a};
    js> a.next = b; // cycle is created here
    [object Object]
    js> print(a.next.label);
    b
    js> print(a.next.next.label);
    a
    js> print(a.next.next.next.label);
    b
    js> print(a.next.next.next.next.label);
    a
    

提交回复
热议问题