Typescript converts an array of circular referenced objects into strings, and as a result, some data becomes null or is added to null, solving!

the following parameters are passed in:
[{

]
"id": "02c76c921d5011e987c600163e0e2174",
"code": "02c76c921d5011e987c600163e0e2174",
"fullTitle": "test,test-t",
"parentId": "e8bbcff61d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": false,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "e8bbcff61d4f11e987c600163e0e2174",
    "code": "e8bbcff61d4f11e987c600163e0e2174",
    "fullTitle": "test",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "2473dea61d5011e987c600163e0e2174",
        "code": "2473dea61d5011e987c600163e0e2174",
        "fullTitle": "test,test-e",
        "parentId": "e8bbcff61d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "34",
        "seq": 2,
        "isLabelShow": true,
        "isInputShow": false,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 401,
    "seq": 6,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "234",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

}, {

"id": "02c76c921d5011e987c600163e0e2174",
"code": "02c76c921d5011e987c600163e0e2174",
"fullTitle": "test,test-e",
"parentId": "e8bbcff61d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": false,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "e8bbcff61d4f11e987c600163e0e2174",
    "code": "e8bbcff61d4f11e987c600163e0e2174",
    "fullTitle": "test",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "2473dea61d5011e987c600163e0e2174",
        "code": "2473dea61d5011e987c600163e0e2174",
        "fullTitle": "test,test-e",
        "parentId": "e8bbcff61d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "34",
        "seq": 2,
        "isLabelShow": true,
        "isInputShow": false,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 401,
    "seq": 6,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "234",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

}, {

"id": "35f29a5e1d5011e987c600163e0e2174",
"code": "35f29a5e1d5011e987c600163e0e2174",
"fullTitle": "test-sun,test-u",
"parentId": "f24bd87b1d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": true,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "f24bd87b1d4f11e987c600163e0e2174",
    "code": "f24bd87b1d4f11e987c600163e0e2174",
    "fullTitle": "test-sun",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "0ef954591d5011e987c600163e0e2174",
        "code": "0ef954591d5011e987c600163e0e2174",
        "fullTitle": "test-sun,test-s",
        "parentId": "f24bd87b1d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "456",
        "seq": 2,
        "isLabelShow": false,
        "isInputShow": true,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 402,
    "seq": 7,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "454",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

}, {

"id": "02c76c921d5011e987c600163e0e2174",
"code": "02c76c921d5011e987c600163e0e2174",
"fullTitle": "test,test-n",
"parentId": "e8bbcff61d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": false,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "e8bbcff61d4f11e987c600163e0e2174",
    "code": "e8bbcff61d4f11e987c600163e0e2174",
    "fullTitle": "test",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "2473dea61d5011e987c600163e0e2174",
        "code": "2473dea61d5011e987c600163e0e2174",
        "fullTitle": "test,test-e",
        "parentId": "e8bbcff61d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "34",
        "seq": 2,
        "isLabelShow": true,
        "isInputShow": false,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 401,
    "seq": 6,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "234",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

}]
let str = JSON.stringify (pd, function (key: any, value: any) {

    if (typeof value === "object" && value !== null) {
        if (cache.indexOf(value) !== -1) {
            return;
        }
        cache.push(value);
    }
    
    return value;

});
is used to convert the above code. The
result should return an array with four objects, but two of them become null. Solve! Thank you!
[{

]
"id": "02c76c921d5011e987c600163e0e2174",
"code": "02c76c921d5011e987c600163e0e2174",
"fullTitle": "test,test-t",
"parentId": "e8bbcff61d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": false,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "e8bbcff61d4f11e987c600163e0e2174",
    "code": "e8bbcff61d4f11e987c600163e0e2174",
    "fullTitle": "test",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "2473dea61d5011e987c600163e0e2174",
        "code": "2473dea61d5011e987c600163e0e2174",
        "fullTitle": "test,test-e",
        "parentId": "e8bbcff61d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "34",
        "seq": 2,
        "isLabelShow": true,
        "isInputShow": false,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 401,
    "seq": 6,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "234",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

},
null,
{

"id": "35f29a5e1d5011e987c600163e0e2174",
"code": "35f29a5e1d5011e987c600163e0e2174",
"fullTitle": "test-sun,test-u",
"parentId": "f24bd87b1d4f11e987c600163e0e2174",
"_checked": false,
"isChecked": false,
"selected": true,
"hovered": false,
"expanded": true,
"load": true,
"parent": {
    "id": "f24bd87b1d4f11e987c600163e0e2174",
    "code": "f24bd87b1d4f11e987c600163e0e2174",
    "fullTitle": "test-sun",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [null, {
        "id": "0ef954591d5011e987c600163e0e2174",
        "code": "0ef954591d5011e987c600163e0e2174",
        "fullTitle": "test-sun,test-s",
        "parentId": "f24bd87b1d4f11e987c600163e0e2174",
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "level": 2,
        "isShow": true,
        "spaceHtml": "<i class="ms-tree-space"></i>",
        "hasChildren": false,
        "sort": "456",
        "seq": 2,
        "isLabelShow": false,
        "isInputShow": true,
        "showInput": false,
        "type": "editSort"
    }],
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": null,
    "level": 1,
    "isShow": true,
    "spaceHtml": "",
    "hasChildren": true,
    "sort": 402,
    "seq": 7,
    "isLabelShow": true,
    "isInputShow": false,
    "showInput": false
},
"level": 2,
"isShow": true,
"spaceHtml": "<i class="ms-tree-space"></i>",
"hasChildren": false,
"sort": "454",
"seq": 1,
"isLabelShow": true,
"isInputShow": false,
"showInput": false,
"type": "editSort"

}, null]

May.23,2022

it doesn't make much sense for you to release the results, you just send out your conversion method, but not the conversion object.
I guess there should be something wrong with your judgment


JSON.stringify<br>import circularJson from 'circular-json';<br>parent<br>[{

"id": 0,
"code": 0,
"name": "save",
"status": "",
"remark": "",
"parentId": 0,
"_checked": false,
"isChecked": false,
"children": [{
    "id": 0,
    "code": 0,
    "name": "s",
    "status": "",
    "remark": "",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "children": [{
        "id": 0,
        "code": 0,
        "name": "ss",
        "status": "",
        "remark": "",
        "parentId": 0,
        "_checked": false,
        "isChecked": false,
        "selected": false,
        "hovered": false,
        "expanded": true,
        "load": true,
        "parent": "~0~children~0",
        "level": 3,
        "isShow": true,
        "spaceHtml": "<i class='ms-tree-space'></i><i class='ms-tree-space'></i>",
        "hasChildren": false,
        "seq": 1,
        "sort": 0,
        "isLabelShow": false,
        "isInputShow": true,
        "type": "insert"
    }],
    "selected": true,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": "~0",
    "level": 2,
    "isShow": true,
    "spaceHtml": "<i class='ms-tree-space'></i>",
    "hasChildren": false,
    "seq": 1,
    "sort": 0,
    "isLabelShow": true,
    "isInputShow": false,
    "type": "insert"
}, {
    "id": 0,
    "code": 0,
    "name": "a",
    "status": "",
    "remark": "",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": "~0",
    "level": 2,
    "isShow": true,
    "spaceHtml": "<i class='ms-tree-space'></i>",
    "hasChildren": false,
    "seq": 2,
    "sort": 0,
    "isLabelShow": true,
    "isInputShow": false,
    "type": "insert"
}, {
    "id": 0,
    "code": 0,
    "name": "v",
    "status": "",
    "remark": "",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": "~0",
    "level": 2,
    "isShow": true,
    "spaceHtml": "<i class='ms-tree-space'></i>",
    "hasChildren": false,
    "seq": 3,
    "sort": 0,
    "isLabelShow": true,
    "isInputShow": false,
    "type": "insert"
}, {
    "id": 0,
    "code": 0,
    "name": "e",
    "status": "",
    "remark": "",
    "parentId": 0,
    "_checked": false,
    "isChecked": false,
    "selected": false,
    "hovered": false,
    "expanded": true,
    "load": true,
    "parent": "~0",
    "level": 2,
    "isShow": true,
    "spaceHtml": "<i class='ms-tree-space'></i>",
    "hasChildren": false,
    "seq": 4,
    "sort": 0,
    "isLabelShow": true,
    "isInputShow": false,
    "type": "insert"
}],
"selected": false,
"hovered": false,
"expanded": true,
"load": true,
"parent": null,
"level": 1,
"isShow": true,
"spaceHtml": "",
"hasChildren": false,
"seq": 33,
"sort": 0,
"isLabelShow": true,
"isInputShow": false,
"type": "insert"

}]

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e6279b-459af.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e6279b-459af.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?