{"id":566,"date":"2022-12-30T21:15:16","date_gmt":"2022-12-30T12:15:16","guid":{"rendered":"http:\/\/attacktube.com\/?p=566"},"modified":"2023-01-15T08:01:54","modified_gmt":"2023-01-14T23:01:54","slug":"javascript-json-parse%e3%81%a8json-stringify","status":"publish","type":"post","link":"https:\/\/attacktube.com\/?p=566","title":{"rendered":"JavaScript JSON.parse\u30e1\u30bd\u30c3\u30c9\u3068JSON.stringify\u30e1\u30bd\u30c3\u30c9"},"content":{"rendered":"\n<p>\u6587\u5b57\u5217\u3092JSON\u3068\u3057\u3066\u89e3\u6790\u3057\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3059\u308b\u3002<br>\u3053\u306e\u3068\u304d\u306f\u3001JSON.parse()\u3092\u4f7f\u7528\u3059\u308b\u3002<br>\u79c1\u306f\u300c\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u3044\u3066\u3042\u308b\u6587\u5b57\u5217\u300d\u3092JSON\u3068\u3057\u3066\u89e3\u6790\u3059\u308b\u3053\u3068\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u3002<br>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092JSON\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u305f\u3044\u3002<br>\u3053\u306e\u3068\u304d\u306f\u3001JSON.stringify()\u3092\u4f7f\u7528\u3059\u308b\u3002<br><br>\u300cparse\u300d\u306f\u300e\u69cb\u6587\u89e3\u6790\u3059\u308b\u300f\u3063\u3066\u610f\u5473\u3002<br>\u300cstringify\u300d\u306f\u82f1\u8a9e\u306e\u8f9e\u66f8\u306b\u8f09\u3063\u3066\u306a\u3044\u306a\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<br>\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3461056110605997\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3461056110605997\" data-ad-slot=\"3137443461\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n<br>\n\n\n\n<pre><code>\nconst json2 = '{\"item\":[{\"itemCode\":\"1 - 1\",\"date\":\"20221229(\u6728)\",\"description\":\"hello\"},{\"itemCode\":\"2 - 1\",\"date\":\"20221230(\u91d1)\",\"description\":\"hello2\"}]}';\n\nconst obj2 = JSON.parse(json2);\n\nconsole.log(\"obj2.item.length = \" + obj2.item.length);\nconsole.log(\"typeof obj2 = \" + typeof obj2);\n\nfor (var i = 0; i &lt; obj2.item.length; i += 1) {\n    console.log(\"obj2.item[\" + i + \"].itemCode = \" + obj2.item[i].itemCode);\n    console.log(\"obj2.item[\" + i + \"].date = \" + obj2.item[i].date);\n    console.log(\"obj2.item[\" + i + \"].description = \" + obj2.item[i].description);\n}\n\nvar str = JSON.stringify(obj2);\n\nconsole.log(\"typeof str = \" + typeof str);\nconsole.log(\"str = \" + str);\n\n\/*\n\nobj2.item.length = 2\ntypeof obj2 = object\nobj2.item[0].itemCode = 1 - 1\nobj2.item[0].date = 20221229(\u6728)\nobj2.item[0].description = hello\nobj2.item[1].itemCode = 2 - 1\nobj2.item[1].date = 20221230(\u91d1)\nobj2.item[1].description = hello2\ntypeof str = string\nstr = {\"item\":[{\"itemCode\":\"1 - 1\",\"date\":\"20221229(\u6728)\",\"description\":\"hello\"},{\"itemCode\":\"2 - 1\",\"date\":\"20221230(\u91d1)\",\"description\":\"hello2\"}]}\n\n*\/\n<\/code><\/pre>\n\n\n\n<p>\u79c1\u306f\u3001JSON.parse()\u3068JSON.stringify()\u306f\u3053\u306e\u4f7f\u3044\u65b9\u3057\u304b\u3057\u3066\u306a\u3044\u306a\u3002\u30aa\u30d7\u30b7\u30e7\u30f3\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u4f7f\u3063\u305f\u3053\u3068\u306a\u3044\u3002<\/p>\n\n\n\n<p>jQuery.parseJSON()\u3068JSON.parse()\u306b\u3064\u3044\u3066\u306f\u4ee5\u524d\u8a18\u4e8b\u306b\u3057\u305f\u3002<br><a href=\"http:\/\/attacktube.com\/?p=215\">jQuery.parseJSON()\u3068JSON.parse()<\/a><br><\/p>\n\n\n\n<script type=\"text\/javascript\">\njQuery(function($){\n$(\".jp-video\").hide();\n});\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u5b57\u5217\u3092JSON\u3068\u3057\u3066\u89e3\u6790\u3057\u3066\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3059\u308b\u3002\u3053\u306e\u3068\u304d\u306f\u3001JSON.parse()\u3092\u4f7f\u7528\u3059\u308b\u3002\u79c1\u306f\u300c\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u3044\u3066\u3042\u308b\u6587\u5b57\u5217\u300d\u3092JSON\u3068\u3057\u3066\u89e3\u6790\u3059\u308b\u3053\u3068\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u3002\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092JSON\u6587\u5b57\u5217\u306b\u5909 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-566","post","type-post","status-publish","format-standard","hentry","category-javascript"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=566"}],"version-history":[{"count":4,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":960,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/566\/revisions\/960"}],"wp:attachment":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}