{"id":232,"date":"2021-04-09T22:02:11","date_gmt":"2021-04-09T14:02:11","guid":{"rendered":"http:\/\/gjweb.top\/?p=232"},"modified":"2021-04-09T22:02:13","modified_gmt":"2021-04-09T14:02:13","slug":"%e6%b7%b1%e6%8b%b7%e8%b4%9d","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=232","title":{"rendered":"\u6df1\u62f7\u8d1d"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5b9e\u73b0\u4e00 : JSON\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>var a = {\n    b:1,\n    c:&#91;1,2,3],\n    d:{c1:'cccc1',c2:'cccc2'}\n}\nvar str = JSON.parse(JSON.string(a))<\/code><\/pre>\n\n\n\n<p>\u7f3a\u70b9:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u53cd\u5e8f\u5217\u5316\u6df1\u62f7\u8d1d\u4e0d\u652f\u6301\u51fd\u6570<\/li><li>\u4e0d\u652f\u6301undefined<\/li><li>\u4e0d\u652f\u6301\u5f15\u7528<\/li><li>\u4e0d\u652f\u6301Date<\/li><li>\u4e0d\u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f<\/li><li>\u4e0d\u652f\u6301symbol<\/li><\/ul>\n\n\n\n<p>\u5b9e\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u4e0d\u652f\u6301\u5f15\u7528\nvar a = {\n    name:'a'\n}\na.self = a;\nvar str = JSON.parse(JSON.string(a)) \/\/error<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u73b0\u4e8c : \u9012\u5f52\u514b\u9686<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function deepClone(source){\n    if(source instanceof Object){\n        if(source instanceof Array){\n            const dist = new Array();\n            for(let key in source){\n                dist&#91;key] = deepClone(source&#91;key])\n            }\n            return dist\n        }else if(source instanceof Function){\n            const dist = function(){\n                return source.apply(this,arguments)\n            }\n            for(let key in source){\n                dist&#91;key] = deepClone(source&#91;key])\n            }\n            return dist;\n        }else{\n            const dist = new Object();\n            for(let key in source){\n                dist&#91;key] = deepClone(source&#91;key])\n            }\n            return dist\n        }\n    }\n    return source\n}\nmodule.exports = deepClone;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u73b0\u4e00 : JSON\u5e8f\u5217\u5316\u4e0e\u53cd\u5e8f\u5217\u5316 \u7f3a\u70b9: \u53cd\u5e8f\u5217\u5316\u6df1\u62f7\u8d1d\u4e0d\u652f\u6301\u51fd\u6570 \u4e0d\u652f\u6301undefined \u4e0d\u652f\u6301\u5f15\u7528  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-232","post","type-post","status-publish","format-standard","hentry","category-js"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=232"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/232\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}