\u4f8b\u5982\u6211\u4eec\u4ece\u670d\u52a1\u5668\u63a5\u6536\u4e86\u4ee5\u4e0b\u6570\u636e\uff1a<\/p>\n
{ \"name\":\"runoob\", \"alexa\":10000, \"site\":\"lrxjmw.cn\" }<\/pre>\n\u6211\u4eec\u4f7f\u7528 JSON.parse() \u65b9\u6cd5\u5904\u7406\u4ee5\u4e0a\u6570\u636e\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a JavaScript \u5bf9\u8c61\uff1a<\/p>\n
var obj = JSON.parse('{ \"name\":\"runoob\", \"alexa\":10000, \"site\":\"www.runoob.com\" }');<\/pre>\n\u89e3\u6790\u524d\u8981\u786e\u4fdd\u4f60\u7684\u6570\u636e\u662f\u6807\u51c6\u7684 JSON \u683c\u5f0f\uff0c\u5426\u5219\u4f1a\u89e3\u6790\u51fa\u9519\u3002<\/p>\n
\u5b9e\u4f8b<\/p>\n
\r\nvar obj = JSON.parse('{ \"name\":\"runoob\", \"alexa\":10000, \"site\":\"lrxjmw.cn\" }');\r\ndocument.getElementById(\"demo\").innerHTML = obj.name + \"\uff1a\" + obj.site;<\/pre>\n\u4ece\u670d\u52a1\u7aef\u63a5\u6536 JSON \u6570\u636e<\/strong><\/div>\n\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 AJAX \u4ece\u670d\u52a1\u5668\u8bf7\u6c42 JSON \u6570\u636e\uff0c\u5e76\u89e3\u6790\u4e3a JavaScript \u5bf9\u8c61\u3002<\/p>\n
\u5b9e\u4f8b<\/p>\n
var xmlhttp = new XMLHttpRequest();\r\nxmlhttp.onreadystatechange = function() {\r\n if (this.readyState == 4 && this.status == 200) {\r\n myObj = JSON.parse(this.responseText);\r\n document.getElementById(\"demo\").innerHTML = myObj.name;\r\n }\r\n};\r\nxmlhttp.open(\"GET\", \"\/try\/ajax\/json_demo.txt\", true);\r\nxmlhttp.send();<\/pre>\n\u4ece\u670d\u52a1\u7aef\u63a5\u6536\u6570\u7ec4\u7684 JSON \u6570\u636e<\/strong><\/div>\n\u5982\u679c\u4ece\u670d\u52a1\u7aef\u63a5\u6536\u7684\u662f\u6570\u7ec4\u7684 JSON \u6570\u636e\uff0c\u5219 JSON.parse \u4f1a\u5c06\u5176\u8f6c\u6362\u4e3a JavaScript \u6570\u7ec4\uff1a<\/p>\n
\u5b9e\u4f8b<\/p>\n
var xmlhttp = new XMLHttpRequest();\r\nxmlhttp.onreadystatechange = function() {\r\n if (this.readyState == 4 && this.status == 200) {\r\n myArr = JSON.parse(this.responseText);\r\n document.getElementById(\"demo\").innerHTML = myArr[1];\r\n }\r\n};\r\nxmlhttp.open(\"GET\", \"\/try\/ajax\/json_demo_array.txt\", true);\r\nxmlhttp.send();<\/pre>\n\u5f02\u5e38<\/strong><\/div>\n\u89e3\u6790\u6570\u636e
\nJSON \u4e0d\u80fd\u5b58\u50a8 Date \u5bf9\u8c61\u3002<\/p>\n
\u5982\u679c\u4f60\u9700\u8981\u5b58\u50a8 Date \u5bf9\u8c61\uff0c\u9700\u8981\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n
\u4e4b\u540e\u518d\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a Date \u5bf9\u8c61\u3002<\/p>\n
\u5b9e\u4f8b<\/p>\n
var text = '{ \"name\":\"Runoob\", \"initDate\":\"2013-12-14\", \"site\":\"www.runoob.com\"}';\r\nvar obj = JSON.parse(text);\r\nobj.initDate = new Date(obj.initDate);\r\n \r\ndocument.getElementById(\"demo\").innerHTML = obj.name + \"\u521b\u5efa\u65e5\u671f: \" + obj.initDate;<\/pre>\n\u6211\u4eec\u53ef\u4ee5\u542f\u7528 JSON.parse \u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570 reviver\uff0c\u4e00\u4e2a\u8f6c\u6362\u7ed3\u679c\u7684\u51fd\u6570\uff0c\u5bf9\u8c61\u7684\u6bcf\u4e2a\u6210\u5458\u8c03\u7528\u6b64\u51fd\u6570\u3002<\/p>\n
\u5b9e\u4f8b<\/p>\n
var text = '{ \"name\":\"Runoob\", \"initDate\":\"2013-12-14\", \"site\":\"www.runoob.com\"}';\r\nvar obj = JSON.parse(text, function (key, value) {\r\n if (key == \"initDate\") {\r\n return new Date(value);\r\n } else {\r\n return value;\r\n}});\r\n \r\ndocument.getElementById(\"demo\").innerHTML = obj.name + \"\u521b\u5efa\u65e5\u671f\uff1a\" + obj.initDate;\r\n<\/pre>\n\u89e3\u6790\u51fd\u6570<\/strong><\/div>\nJSON \u4e0d\u5141\u8bb8\u5305\u542b\u51fd\u6570\uff0c\u4f46\u4f60\u53ef\u4ee5\u5c06\u51fd\u6570\u4f5c\u4e3a\u5b57\u7b26\u4e32\u5b58\u50a8\uff0c\u4e4b\u540e\u518d\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u51fd\u6570\u3002<\/p>\n
\u5b9e\u4f8b<\/p>\n
var text = '{ \"name\":\"Runoob\", \"alexa\":\"function () {return 10000;}\", \"site\":\"www.runoob.com\"}';\r\nvar obj = JSON.parse(text);\r\nobj.alexa = […]<\/p>\n","protected":false},"author":1481,"featured_media":223326,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-223336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1481"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=223336"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223336\/revisions"}],"predecessor-version":[{"id":223342,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/223336\/revisions\/223342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/223326"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=223336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=223336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=223336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}