{"id":42336,"date":"2024-12-01T14:25:57","date_gmt":"2024-12-01T06:25:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/42336\/"},"modified":"2024-12-01T14:25:57","modified_gmt":"2024-12-01T06:25:57","slug":"%e5%b0%86-json-%e8%a7%a3%e7%bb%84%e4%b8%ba-struct","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/42336\/","title":{"rendered":"\u5c06 JSON \u89e3\u7ec4\u4e3a Struct"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>\u5c06 JSON \u89e3\u7ec4\u4e3a Struct<\/span><\/p>\n<h1>\u5c06 JSON \u89e3\u7ec4\u4e3a Struct<\/h1>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-23 16:09:33<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5728Golang\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5c06 JSON \u89e3\u7ec4\u4e3a Struct\u300b\uff0c\u804a\u804a\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u6b63\u5728\u5c1d\u8bd5\u5c06\u4ee5\u4e0b json \u5b57\u7b26\u4e32\u89e3\u7ec4\u5230\u4e0b\u9762\u7684\u7ed3\u6784\u4e2d\uff1b<\/p>\n<pre>{\n   \"io.confluent.connect.avro.connectdefault\":{\n      \"lastmodifiedat\":{\n         \"string\":\"2022-09-01t02:22:19+00:00\"\n      },\n      \"taxrateid\":{\n         \"int\":5\n      },\n      \"basedon\":{\n         \"string\":\"markup\"\n      },\n      \"pricetax\":{\n         \"double\":2.04\n      },\n      \"price\":{\n         \"int\":24\n      },\n      \"status\":{\n         \"string\":\"active\"\n      },\n      \"costprice\":{\n         \"int\":24\n      },\n      \"createdat\":{\n         \"string\":\"2022-09-01t02:22:19+00:00\"\n      },\n      \"productid\":{\n         \"int\":3545\n      },\n      \"ownershipid\":{\n         \"int\":1\n      },\n      \"dbid\":{\n         \"int\":3655\n      },\n      \"markuppercentage\":{\n         \"int\":0\n      }\n   }\n}<\/pre>\n<pre>type Wrapper struct {\n    Message `json:\"io.confluent.connect.avro.ConnectDefault\"`\n}\n\ntype Message struct {\n    DbId Field `json:\"dbId\"`\n}\n\ntype Field struct {\n    Value map[string]interface{}\n}<\/pre>\n<p>\u4f46\u5b83\u4e3a\u6211\u63d0\u4f9b\u4e86 <code>field<\/code> \u5730\u56fe\u7684\u7a7a\u503c\u3002\u4e0d\u786e\u5b9a\u6211\u5728\u8fd9\u91cc\u505a\u9519\u4e86\u4ec0\u4e48\u3002<\/p>\n<p> <\/p>\n<h2>\u6b63\u786e\u7b54\u6848<\/h2>\n<p> <\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u4f60\u6709\u989d\u5916\u7684\u5d4c\u5957\u7ea7\u522b\uff1a<\/p>\n<pre>type Message struct {\n    DbId map[string]interface{} `json:\"dbId\"`\n}\n<\/pre>\n<p><code>dbid<\/code> \u5c5e\u6027\u7684\u503c\u662f <code>map<\/code> \u6216 <code>string<\/code> \u7684\u4efb\u610f\u503c\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5c06 JSON \u89e3\u7ec4\u4e3a Struct\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &gt; &gt; \u5c06 JSON \u89e3\u7ec4\u4e3a Struct \u5c06 JSON \u89e3\u7ec4\u4e3a Struct \u6765\u6e90\uff1astackoverflow 2024-04-23 16:09:33 0\u6d4f\u89c8 \u6536\u85cf \u5728Golang\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5c06 JSON \u89e3\u7ec4\u4e3a Struct\u300b\uff0c\u804a\u804a\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002 \u95ee\u9898\u5185\u5bb9 \u6211\u6b63\u5728\u5c1d\u8bd5\u5c06\u4ee5\u4e0b json \u5b57\u7b26\u4e32\u89e3\u7ec4\u5230\u4e0b\u9762\u7684\u7ed3\u6784\u4e2d\uff1b { &#8220;io.confluent.connect.avro.connectdefault&#8221;:{ &#8220;lastmodifiedat&#8221;:{ &#8220;string&#8221;:&#8221;2022-09-01t02:22:19+00:00&#8243; }, &#8220;taxrateid&#8221;:{ &#8220;int&#8221;:5 }, &#8220;basedon&#8221;:{ &#8220;string&#8221;:&#8221;markup&#8221; }, &#8220;pricetax&#8221;:{ &#8220;double&#8221;:2.04 }, &#8220;price&#8221;:{ &#8220;int&#8221;:24 }, &#8220;status&#8221;:{ &#8220;string&#8221;:&#8221;active&#8221; }, &#8220;costprice&#8221;:{ &#8220;int&#8221;:24 }, &#8220;createdat&#8221;:{ &#8220;string&#8221;:&#8221;2022-09-01t02:22:19+00:00&#8243; }, &#8220;productid&#8221;:{ &#8220;int&#8221;:3545 }, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-42336","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/42336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=42336"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/42336\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=42336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=42336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=42336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}