{"id":1114,"date":"2022-01-16T22:01:21","date_gmt":"2022-01-16T13:01:21","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=1114"},"modified":"2022-01-24T07:29:57","modified_gmt":"2022-01-23T22:29:57","slug":"golang-json-marshal-%e3%81%ae%e8%bf%94%e3%81%99%ef%bc%91%e3%81%a4%e7%9b%ae%e3%81%ae%e5%80%a4%e3%81%af-byte-%e5%9e%8b%e3%81%aa%e3%81%ae%e3%81%a7%e3%80%81string%e5%9e%8b%e3%81%abtype-assertion%e3%81%99","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=1114","title":{"rendered":"<small>Golang json.Marshal \u306e\u623b\u308a\u5024\u3092string\u578b\u306b\u5909\u63db<\/small>"},"content":{"rendered":"<p>\uff11\uff0ejson.Marshal \u306e\u623b\u308a\u5024\u306e\u5909\u63db<br \/>\n json.Marshal \u306e\u623b\u308a\u5024\u306e\uff11\u3064\u76ee\u306f byte \u578b\u306a\u306e\u3067\u3001string\u578b\u306btype assertion\u3059\u308b<\/p>\n<p>\uff12\uff0eType Assertion\uff08\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\uff09<br \/>\n\u30fb\u300c\u578b\u30ad\u30e3\u30b9\u30c8\u300d\u3068\u547c\u3070\u308c\u306a\u3044\u7406\u7531<br \/>\n\u30ad\u30e3\u30b9\u30c8\u306f\u4e00\u822c\u7684\u306b\u4f55\u3089\u304b\u306e\u30e9\u30f3\u30bf\u30a4\u30e0\u30b5\u30dd\u30fc\u30c8\u3092\u610f\u5473\u3059\u308b\u3002<br \/>\n\u305d\u308c\u306b\u5bfe\u3057\u3001\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306f\u7d14\u7c8b\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306e\u69cb\u9020\u4f53\u3067\u3042\u308b\u3002<br \/>\n\u3064\u307e\u308a\u3001\u30b3\u30fc\u30c9\u3092\u3069\u306e\u3088\u3046\u306b\u89e3\u6790\u3059\u308b\u304b\u306b\u3064\u3044\u3066\u306e\u30d2\u30f3\u30c8\u3092\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u63d0\u4f9b\u3059\u308b\u305f\u3081\u306e\u65b9\u6cd5\u306b\u3059\u304e\u306a\u3044\u3002<\/p>\n<p>\uff13\uff0ecode<\/p>\n<pre>\r\ntype Users_s struct {\r\n        Id              string `json:\"id\"`\r\n        Sub_id          string `json:\"sub_id\"`\r\n        Attr            string `json:\"attr\"`\r\n}\r\n\r\n\u30fb\u30fb\u30fb\r\nvar users Users_s\r\n\r\nbytes, _ := json.Marshal(attr);\r\nusers.Attr = string(bytes);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uff11\uff0ejson.Marshal \u306e\u623b\u308a\u5024\u306e\u5909\u63db json.Marshal \u306e\u623b\u308a\u5024\u306e\uff11\u3064\u76ee\u306f byte \u578b\u306a\u306e\u3067\u3001string\u578b\u306btype assertion\u3059\u308b \uff12\uff0eType Assertion\uff08\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\uff09 \u30fb\u300c\u578b&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1114"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1114"}],"version-history":[{"count":8,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1114\/revisions"}],"predecessor-version":[{"id":1129,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/1114\/revisions\/1129"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}