{"id":812,"date":"2021-03-05T17:20:42","date_gmt":"2021-03-05T08:20:42","guid":{"rendered":"http:\/\/www.opentone.co.jp\/ot-lab\/?p=812"},"modified":"2025-05-12T10:06:20","modified_gmt":"2025-05-12T01:06:20","slug":"json_encode","status":"publish","type":"post","link":"https:\/\/www.opentone.co.jp\/ot-lab\/all\/web-system\/json_encode","title":{"rendered":"json_encode\u3067\u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u6587\u5b57\u3092\u30a8\u30f3\u30b3\u30fc\u30c9"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\u3002ishiB\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u5148\u65e5\u3001PHP\u3067 json_encode \u3092\u4f7f\u3063\u305f smarty \u306e plugin \u3092\u4f5c\u6210\u3059\u308b\u6a5f\u4f1a\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br>\u305d\u306e\u3068\u304d\u306b\u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u306e\u6271\u3044\u3067\u5c11\u3057\u30cf\u30de\u3063\u305f\u306e\u3067\u3001\u5185\u5bb9\u3092\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\uff09<a href=\"http:\/\/www.smarty.net\/docsv2\/ja\/\" target=\"_blank\" rel=\"noreferrer noopener\">smarty\u3068\u306f\uff1f<\/a><\/p>\n\n\n\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u914d\u5217\u3092\u7d44\u307f\u7acb\u3066\u305f\u5f8c\u3001json_encode\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n&lt;?php\n    $title = '\u30bf\u30a4\u30c8\u30eb'\n    $json = array('title' =&gt; $title,\n                  'body'  =&gt; 'test');\n    echo json_encode($json);\n?&gt;\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u3068\u3057\u305f\u3068\u3053\u308d\u3001\u671f\u5f85\u3057\u3066\u3044\u305f\u7d50\u679c\u306f\u3001<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n{\"title\":\"\u30bf\u30a4\u30c8\u30eb\",\"body\":\"test\"}\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u3060\u3063\u305f\u3093\u3067\u3059\u304c\u3001<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n{\"title\":null,\"body\":\"test\"}\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u3068\u3044\u3046\u7d50\u679c\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u3001php\u306e\u30b3\u30fc\u30c9\u304ceuc-jp\u3067\u8a18\u8ff0\u3055\u308c\u3066\u3044\u305f\u3053\u3068\u304c\u539f\u56e0\u3067\u3001<br><a href=\"http:\/\/php.net\/manual\/ja\/function.json-encode.php\" target=\"_blank\" rel=\"noreferrer noopener\">PHP\u30de\u30cb\u30e5\u30a2\u30eb<\/a>\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u300c\u3059\u3079\u3066\u306e\u6587\u5b57\u5217\u30c7\u30fc\u30bf\u306f\u3001UTF-8 \u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u3044\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3002\u300d\u3068\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3067\u4e0b\u8a18\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n&lt;?php\n    $title = '\u30bf\u30a4\u30c8\u30eb'\n    $json = array('title' =&gt; mb_convert_encoding($title, \"UTF-8\", \"EUC-JP\"),\n                  'body'  =&gt; 'test');\n    $json = mb_convert_encoding($json, \"EUC-JP\", \"UTF-8\")\n    json_encode($json);\n?&gt;\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u305d\u3046\u3059\u308b\u3068\u4eca\u5ea6\u306f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n{\"title\":\"\\u30BF\\u30A4\\u30C8\\u30EB\",\"body\":\"test\"}\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u3068\u3044\u3046\u7d50\u679c\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3069\u3046\u3084\u3089\u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u7b2c\u4e8c\u5f15\u6570\u306b JSON_UNESCAPED_UNICODE \u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u203b\u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306fPHP5.4\u304b\u3089\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br>PHP5.4\u4ee5\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306fhex2bin\u306a\u3069\u3092\u4f7f\u3044\u3082\u3046\u4e00\u624b\u9593\u304b\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[sourcecode language=\"php\"]\n&lt;?php\n    $title = '\u30bf\u30a4\u30c8\u30eb'\n    $json = array('title' =--&gt; mb_convert_encoding($title, \"UTF-8\", \"EUC-JP\"),\n                  'body'  =&gt; 'test');\n    $json = mb_convert_encoding($json, \"EUC-JP\", \"UTF-8\")\n    json_encode($json);\n?&gt;\n[\/sourcecode]<\/pre>\n\n\n\n<p>\u3068\u3059\u308b\u3053\u3068\u3067\u3001\u3084\u3063\u3068\u671f\u5f85\u3057\u3066\u3044\u305f\u901a\u308a\u306e\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u540c\u3058\u3088\u3046\u306a\u4e8b\u8c61\u306b\u906d\u9047\u3057\u3066\u3044\u308b\u65b9\u306a\u3069\u306e\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n<div class=\"opent-_2\" style=\"margin-top: 10px;margin-right: 10px;margin-bottom: 10px;margin-left: 10px;\" id=\"opent-1381547421\"><a href=\"https:\/\/www.opentone.co.jp\/backlog\/\" aria-label=\"twitter_backlogskt_new\"><img src=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg\" alt=\"\"  srcset=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg 1024w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-300x157.jpg 300w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-768x401.jpg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"384\" height=\"200\"   \/><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002ishiB\u3067\u3059\u3002 \u5148\u65e5\u3001PHP\u3067 json_encode \u3092\u4f7f\u3063\u305f smarty \u306e p<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28],"tags":[8],"class_list":["post-812","post","type-post","status-publish","format-standard","hentry","category-web-system","tag-blog",""],"acf":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"engage-mag-carousel-img":false,"engage-mag-carousel-img-landscape":false,"engage-mag-carousel-large-img":false,"engage-mag-carousel-large-img-landscape":false,"engage-mag-large-thumb":false,"engage-mag-small-thumb":false},"uagb_author_info":{"display_name":"ah106rx4o4","author_link":"https:\/\/www.opentone.co.jp\/ot-lab\/author\/ah106rx4o4"},"uagb_comment_info":3,"uagb_excerpt":"\u3053\u3093\u306b\u3061\u306f\u3002ishiB\u3067\u3059\u3002 \u5148\u65e5\u3001PHP\u3067 json_encode \u3092\u4f7f\u3063\u305f smarty \u306e p","_links":{"self":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":2,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":815,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/812\/revisions\/815"}],"wp:attachment":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/categories?post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/tags?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}