{"id":794,"date":"2025-08-04T16:20:19","date_gmt":"2025-08-04T07:20:19","guid":{"rendered":"https:\/\/nexive.tech\/?p=794"},"modified":"2025-08-04T16:20:20","modified_gmt":"2025-08-04T07:20:20","slug":"%e3%80%90%e3%82%b5%e3%82%af%e3%83%83%e3%81%a8%e8%a7%a3%e8%aa%ac%e3%80%91php-json%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e8%aa%ad%e3%81%bf%e6%9b%b8%e3%81%8d%e5%87%a6%e7%90%86%ef%bc%88json_encode","status":"publish","type":"post","link":"https:\/\/nexive.tech\/?p=794","title":{"rendered":"\u3010\u30b5\u30af\u30c3\u3068\u89e3\u8aac\u3011PHP JSON\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u51e6\u7406\uff08json_encode\/json_decode\uff09"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u3067JSON\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u66f8\u304d\u3059\u308b\u57fa\u672c\u51e6\u7406\u3092\u89e3\u8aac<\/li>\n\n\n\n<li><code>json_encode<\/code> \/ <code>json_decode<\/code> \u306e\u6b63\u3057\u3044\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9\u3092\u7d39\u4ecb<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30eb\u5165\u51fa\u529b\u3068\u7d44\u307f\u5408\u308f\u305b\u305f\u5b9f\u52d9\u3067\u306e\u5178\u578b\u30d1\u30bf\u30fc\u30f3\u3092\u7db2\u7f85<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. PHP\u306b\u304a\u3051\u308bJSON\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3068\u51fa\u529b\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>PHP\u306f\u6a19\u6e96\u95a2\u6570\u3068\u3057\u3066 <code>json_encode<\/code> \u304a\u3088\u3073 <code>json_decode<\/code> \u3092\u63d0\u4f9b\u3057\u3066\u304a\u308a\u3001JSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002JSON\u306f\u30c7\u30fc\u30bf\u4ea4\u63db\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u3057\u3066\u5e83\u304f\u5229\u7528\u3055\u308c\u3066\u304a\u308a\u3001PHP\u3067\u306fAPI\u901a\u4fe1\u30fb\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u30fb\u30c7\u30fc\u30bf\u306e\u4fdd\u5b58\u306a\u3069\u3001\u3055\u307e\u3056\u307e\u306a\u5834\u9762\u3067\u6d3b\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7279\u306bWeb\u958b\u767a\u3067\u306f\u3001\u5916\u90e8\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u9023\u643a\u3084\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3068\u306e\u30c7\u30fc\u30bf\u53d7\u3051\u6e21\u3057\u306e\u4e2d\u7d99\u306bJSON\u3092\u7528\u3044\u308b\u3053\u3068\u304c\u4e00\u822c\u7684\u3067\u3059\u3002\u307e\u305f\u3001PHP\u306f\u9023\u60f3\u914d\u5217\u3068\u306e\u89aa\u548c\u6027\u304c\u9ad8\u304f\u3001<code>json_decode<\/code> \u3067\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u914d\u5217\u3068\u3057\u3066\u64cd\u4f5c\u3067\u304d\u308b\u70b9\u3082\u7279\u5fb4\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001JSON\u6587\u5b57\u5217\u3068PHP\u914d\u5217\u306e\u76f8\u4e92\u5909\u63db\u3001\u30d5\u30a1\u30a4\u30eb\u3068\u306e\u9023\u643a\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u307e\u3067\u3092\u4e00\u901a\u308a\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u8a73\u7d30\u89e3\u8aac<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">JSON\u6587\u5b57\u5217\u304b\u3089PHP\u306e\u914d\u5217\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\uff08<code>json_decode<\/code>\uff09<\/h3>\n\n\n\n<p>\u5916\u90e8\u304b\u3089\u53d7\u3051\u53d6\u3063\u305fJSON\u6587\u5b57\u5217\u3092\u914d\u5217\u3068\u3057\u3066\u6271\u3044\u305f\u3044\u5834\u5408\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$json = '{\"name\":\"Taro\",\"age\":20}';\n$data = json_decode($json, true); \/\/ \u7b2c2\u5f15\u6570\u306btrue\u3092\u6307\u5b9a\u3059\u308b\u3068\u9023\u60f3\u914d\u5217\u3067\u8fd4\u308b\nprint_r($data);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #CE9178\">&#39;{&quot;name&quot;:&quot;Taro&quot;,&quot;age&quot;:20}&#39;<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">json_decode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #569CD6\">true<\/span><span style=\"color: #D4D4D4\">); <\/span><span style=\"color: #6A9955\">\/\/ \u7b2c2\u5f15\u6570\u306btrue\u3092\u6307\u5b9a\u3059\u308b\u3068\u9023\u60f3\u914d\u5217\u3067\u8fd4\u308b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">print_r<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>Array\n(\n    &#91;name&#93; => Taro\n    &#91;age&#93; => 20\n)\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">Array<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;name&#93; =&gt; Taro<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    &#91;age&#93; =&gt; <\/span><span style=\"color: #B5CEA8\">20<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u7b2c2\u5f15\u6570\u3092\u7701\u7565\u307e\u305f\u306ffalse\u306b\u3059\u308b\u3068\u3001stdClass\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$obj = json_decode($json);\necho $obj->name; \/\/ \"Taro\"\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$obj<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">json_decode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$obj<\/span><span style=\"color: #D4D4D4\">-&gt;<\/span><span style=\"color: #9CDCFE\">name<\/span><span style=\"color: #D4D4D4\">; <\/span><span style=\"color: #6A9955\">\/\/ &quot;Taro&quot;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PHP\u306e\u914d\u5217\/\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092JSON\u6587\u5b57\u5217\u306b\u5909\u63db\uff08<code>json_encode<\/code>\uff09<\/h3>\n\n\n\n<p>\u30c7\u30fc\u30bf\u3092JSON\u5f62\u5f0f\u3067\u4fdd\u5b58\u3057\u305f\u308a\u3001JavaScript\u5074\u306b\u6e21\u3059\u969b\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$data = &#91;\"name\" => \"Hanako\", \"age\" => 25&#93;;\n$json = json_encode($data);\necho $json;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\"> = &#91;<\/span><span style=\"color: #CE9178\">&quot;name&quot;<\/span><span style=\"color: #D4D4D4\"> =&gt; <\/span><span style=\"color: #CE9178\">&quot;Hanako&quot;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;age&quot;<\/span><span style=\"color: #D4D4D4\"> =&gt; <\/span><span style=\"color: #B5CEA8\">25<\/span><span style=\"color: #D4D4D4\">&#93;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">json_encode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u51fa\u529b\u7d50\u679c\uff1a<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>{\"name\":\"Hanako\",\"age\":25}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">{<\/span><span style=\"color: #CE9178\">&quot;name&quot;<\/span><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #CE9178\">&quot;Hanako&quot;<\/span><span style=\"color: #D4D4D4\">,<\/span><span style=\"color: #CE9178\">&quot;age&quot;<\/span><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #B5CEA8\">25<\/span><span style=\"color: #D4D4D4\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">JSON\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u76f4\u63a5JSON\u3092\u8aad\u307f\u8fbc\u3093\u3067\u914d\u5217\u306b\u5909\u63db\u3059\u308b\u306b\u306f\u3001<code>file_get_contents<\/code> \u3068 <code>json_decode<\/code> \u3092\u7d44\u307f\u5408\u308f\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$json = file_get_contents('data.json');\n$data = json_decode($json, true);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">file_get_contents<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;data.json&#39;<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">json_decode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$json<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #569CD6\">true<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u306e\u65b9\u6cd5\u306f\u30ed\u30fc\u30ab\u30eb\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3084\u30ad\u30e3\u30c3\u30b7\u30e5\u30c7\u30fc\u30bf\u306a\u3069\u306e\u8aad\u307f\u8fbc\u307f\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u914d\u5217\u3092JSON\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3059\u308b<\/h3>\n\n\n\n<p>JSON\u5f62\u5f0f\u3067\u4fdd\u5b58\u3059\u308b\u306b\u306f <code>json_encode<\/code> \u3057\u305f\u6587\u5b57\u5217\u3092 <code>file_put_contents<\/code> \u3067\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n$data = &#91;\"status\" => \"ok\", \"timestamp\" => time()&#93;;\nfile_put_contents('result.json', json_encode($data, JSON_PRETTY_PRINT));\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">&lt;?php<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\"> = &#91;<\/span><span style=\"color: #CE9178\">&quot;status&quot;<\/span><span style=\"color: #D4D4D4\"> =&gt; <\/span><span style=\"color: #CE9178\">&quot;ok&quot;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">&quot;timestamp&quot;<\/span><span style=\"color: #D4D4D4\"> =&gt; <\/span><span style=\"color: #DCDCAA\">time<\/span><span style=\"color: #D4D4D4\">()&#93;;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #DCDCAA\">file_put_contents<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&#39;result.json&#39;<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #DCDCAA\">json_encode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\">, JSON_PRETTY_PRINT));<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>JSON_PRETTY_PRINT<\/code> \u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u6574\u5f62\u3055\u308c\u305f\u51fa\u529b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u3088\u304f\u3042\u308b\u30df\u30b9\u30fb\u8aa4\u89e3\u30fb\u843d\u3068\u3057\u7a74<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>json_decode<\/code> \u306e\u7b2c2\u5f15\u6570\u3092\u5fd8\u308c\u308b\u3068\u3001\u9023\u60f3\u914d\u5217\u3067\u306f\u306a\u304f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u8fd4\u308b\u305f\u3081\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>json_encode<\/code> \u306b\u7279\u6b8a\u6587\u5b57\uff08\u65e5\u672c\u8a9e\u30fb\u5236\u5fa1\u6587\u5b57\u306a\u3069\uff09\u3092\u542b\u3080\u3068\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u3066\u8aad\u307f\u306b\u304f\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u306f <code>JSON_UNESCAPED_UNICODE<\/code> \u3092\u4ed8\u3051\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e\"><span style=\"background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e\">PHP<\/span><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>json_encode($data, JSON_UNESCAPED_UNICODE);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">json_encode<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">$data<\/span><span style=\"color: #D4D4D4\">, JSON_UNESCAPED_UNICODE);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JSON\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u6642\u306b\u6587\u5b57\u30b3\u30fc\u30c9\uff08UTF-8\uff09\u3067\u306a\u3044\u3068\u51e6\u7406\u306b\u5931\u6557\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u7279\u306bWindows\u74b0\u5883\u3067\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/li>\n\n\n\n<li>\u30a8\u30f3\u30b3\u30fc\u30c9\u30fb\u30c7\u30b3\u30fc\u30c9\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306f <code>json_last_error()<\/code> \u3067\u30a8\u30e9\u30fc\u5185\u5bb9\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u307e\u3068\u3081<\/h2>\n\n\n\n<p>PHP\u3067\u306f <code>json_encode<\/code> \/ <code>json_decode<\/code> \u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001JSON\u30c7\u30fc\u30bf\u3068\u306e\u76f8\u4e92\u5909\u63db\u304c\u7c21\u5358\u306b\u884c\u3048\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u95a2\u6570\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u3084\u30ad\u30e3\u30c3\u30b7\u30e5\u7ba1\u7406\u306a\u3069\u3001\u5b9f\u52d9\u3067\u3082\u983b\u51fa\u3059\u308b\u51e6\u7406\u304c\u69cb\u7bc9\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305f\u3060\u3057\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3084\u5f15\u6570\u306e\u6307\u5b9a\u306a\u3069\u3067\u60f3\u5b9a\u5916\u306e\u6319\u52d5\u306b\u306a\u308b\u3053\u3068\u3082\u3042\u308b\u305f\u3081\u3001\u5e38\u306b\u51fa\u529b\u3068\u30a8\u30e9\u30fc\u78ba\u8a8d\u3092\u610f\u8b58\u3057\u305f\u5b9f\u88c5\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u672c\u8a18\u4e8b\u306e\u30dd\u30a4\u30f3\u30c8 2. PHP\u306b\u304a\u3051\u308bJSON\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u3068\u51fa\u529b\u3068\u306f\uff1f PHP\u306f\u6a19\u6e96\u95a2\u6570\u3068\u3057\u3066 json_encode \u304a\u3088\u3073 json_decode \u3092\u63d0\u4f9b\u3057\u3066\u304a\u308a\u3001JSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u6271\u3046\u3053\u3068\u304c\u3067 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":712,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[85],"tags":[],"class_list":["post-794","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=794"}],"version-history":[{"count":2,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/794\/revisions"}],"predecessor-version":[{"id":880,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/posts\/794\/revisions\/880"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=\/wp\/v2\/media\/712"}],"wp:attachment":[{"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nexive.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}