{"id":3853,"date":"2023-07-14T13:28:51","date_gmt":"2023-07-14T04:28:51","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=3853"},"modified":"2023-07-14T13:28:51","modified_gmt":"2023-07-14T04:28:51","slug":"%e3%80%90go%e3%80%91json%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf%e5%9f%ba%e6%9c%ac-%e3%83%95%e3%82%a3%e3%83%bc%e3%83%ab%e3%83%89%e3%83%9e%e3%83%83%e3%83%94%e3%83%b3%e3%82%b0","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=3853","title":{"rendered":"\u3010Go\u3011Json\u8aad\u307f\u8fbc\u307f\u57fa\u672c &#8211; \u30d5\u30a3\u30fc\u30eb\u30c9\u30de\u30c3\u30d4\u30f3\u30b0"},"content":{"rendered":"\n<p>json\u306e\u30ad\u30fc\u540d\u306f\u30b9\u30cd\u30fc\u30af\u30b1\u30fc\u30b9(ex full_name)\u3067\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u4e8b\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u3001json\u306e\u30ad\u30fc\u540d\u3068\u69cb\u9020\u4f53\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u3092\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u305b\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30ebJSON\u30d5\u30a1\u30a4\u30eb<\/h1>\n\n\n\n<p>\u30ad\u30fc\u540d\u3092\u30b9\u30cd\u30fc\u30af\u30b1\u30fc\u30b9\u3067\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-json\" data-lang=\"JSON\"><code>{\n    &quot;name&quot;: &quot;sample_name&quot;,\n    &quot;events&quot;: [\n        {\n            &quot;age&quot;: 18,\n            &quot;name&quot;: &quot;\u5352\u696d&quot;,\n            &quot;date_time&quot;: &quot;2002-03-30 12:12:12&quot;\n        },\n        {\n            &quot;age&quot;: 22,\n            &quot;name&quot;: &quot;\u5165\u793e&quot;,\n            &quot;date_time&quot;: &quot;2005-04-01 09:00:00&quot;\n        }\n    ]\n}<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u69cb\u9020\u4f53\u30d5\u30a3\u30fc\u30eb\u30c9\u30de\u30c3\u30d4\u30f3\u30b0<\/h1>\n\n\n\n<p>\u69cb\u9020\u4f53\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3078\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u305b\u308b\u306b\u306f\u3001\u69cb\u9020\u4f53\u3092\u5b9a\u7fa9\u3059\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3078\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8a18\u8ff0\u3092\u3057\u307e\u3059\u3002example \u306e\u8a18\u8f09\u306f\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>type event struct {\n\tAge      int    `json:&quot;age&quot; example:&quot;10&quot;`\n\tName     string `json:&quot;name&quot; example:&quot;eventName&quot;`\n\tDateTime string `json:&quot;date_time&quot; example:&quot;2022-12-12 12:12:12&quot;`\n}<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb\u51e6\u7406<\/h1>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>package main\n\nimport (\n\t&quot;encoding\/json&quot;\n\t&quot;fmt&quot;\n\t&quot;os&quot;\n)\n\n\/\/ Json\u306e\u5185\u5bb9\u3092\u683c\u7d0d\u3059\u308b\u69cb\u9020\u4f53\ntype history struct {\n\tName   string  `json:&quot;name&quot; example:&quot;sampleName&quot;`\n\tEvents []event `json:&quot;events&quot;`\n}\n\ntype event struct {\n\tAge      int    `json:&quot;age&quot; example:&quot;10&quot;`\n\tName     string `json:&quot;name&quot; example:&quot;eventName&quot;`\n\tDateTime string `json:&quot;date_time&quot; example:&quot;2022-12-12 12:12:12&quot;`\n}\n\nfunc main() {\n\n\th := history{}\n\n\t\/\/ \u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\n\tf, err := os.Open(&quot;sample.json&quot;)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t\/\/ \u30c7\u30b3\u30fc\u30c9\n\tjson.NewDecoder(f).Decode(&h)\n\n\t\/\/ \u7d50\u679c\u3092\u8868\u793a\n\tfmt.Println(h) \/\/ {sample_name [{18 \u5352\u696d 2002-03-30 12:12:12} {22 \u5165\u793e 2005-04-01 09:00:00}]}\n}\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>json\u306e\u30ad\u30fc\u540d\u306f\u30b9\u30cd\u30fc\u30af\u30b1\u30fc\u30b9(ex full_name)\u3067\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u4e8b\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":968,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-3853","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3853"}],"version-history":[{"count":1,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3853\/revisions"}],"predecessor-version":[{"id":3854,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3853\/revisions\/3854"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/968"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}