{"id":15428,"date":"2024-05-29T10:29:21","date_gmt":"2024-05-29T02:29:21","guid":{"rendered":"https:\/\/92it.top\/?p=15428"},"modified":"2024-05-29T10:29:21","modified_gmt":"2024-05-29T02:29:21","slug":"messagepack%ef%bc%9a%e6%9c%80%e5%8f%af%e8%83%bd%e5%8f%96%e4%bb%a3json%e7%9a%84%e5%ad%98%e5%9c%a8%e3%80%82","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=15428","title":{"rendered":"MessagePack\uff1a\u6700\u53ef\u80fd\u53d6\u4ee3JSON\u7684\u5b58\u5728\u3002"},"content":{"rendered":"\n<p>\u4eca\u5929\u54b1\u4eec\u804a\u804a\u4e00\u4e2a\u633a\u9177\u7684\u6570\u636e\u5e8f\u5217\u5316\u5de5\u5177\u2014\u2014Msgpack\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u80fd\u542c\u8fc7JSON\uff0c\u5b83\u5728\u6570\u636e\u4ea4\u6362\u9886\u57df\u53ef\u8c13\u662f\u8d85\u7ea7\u660e\u661f\u3002<\/p>\n\n\n\n<p>\u4f46\u4eca\u5929\u8981\u4ecb\u7ecd\u7684\u8fd9\u4e2a\u9009\u624b\uff0cMsgpack\uff0c\u4e0d\u4ec5\u901f\u5ea6\u5feb\uff0c\u4f53\u79ef\u8fd8\u5c0f\uff0c\u5bf9\u4e8e\u5904\u7406\u5927\u6570\u636e\u6765\u8bf4\u662f\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<p>\u79d1\u666e\u4e00\u4e2a\u51b7\u95e8\u7684\uff0c\u4f46\u662f\u5f88\u5f3a\u7684\u6280\u672f\uff1aMessagePack\uff0c\u7b80\u79f0msgpack\u3002msgpack\u4e0d\u662f\u8f6f\u4ef6\uff0c\u662f\u4e00\u4e2a\u6807\u51c6\uff0c\u53ef\u4ee5\u5148\u628a\u5b83\u770b\u6210\u4e8c\u8fdb\u5236\u7684json\uff0c\u201c\u4e8c\u8fdb\u5236json\u201d\u5bb9\u6613\u8ba9\u4eba\u8054\u60f3\u5230\u4e00\u4e2a\u66f4\u6d41\u884c\u4e00\u70b9\u7684\u6807\u51c6\uff1aBSON\u3002\u5982\u679c\u4f60\u4e0d\u77e5\u9053bson\u662f\u5565\u53ef\u4ee5\u53bb\u67e5\u4e00\u4e0b\uff0c\u603b\u4e4bmsgpack\u548cbson\u662f\u540c\u7c7b\u578b\u7684\u7ade\u4e89\u4ea7\u54c1\uff0c\u4f46\u662fmsgpack\u65e0\u8bba\u4ece\u901f\u5ea6\u8fd8\u662f\u4f53\u79ef\u4e0a\u90fd\u79d2\u6740bson\uff0c\u81f3\u5c11\u5728\u7f51\u7edc\u4f20\u8f93\u4e0a\u662f\u8fd9\u6837\u7684\u3002<\/p>\n\n\n\n<p>json\u90fd\u77e5\u9053\u662f\u5565\u5427\uff0c\u5728\u5e8f\u5217\u5316\u9886\u57df\u795e\u4e00\u822c\u7684\u5b58\u5728\u3002\u4ec0\u4e48\u662f\u5e8f\u5217\u5316\u5462\uff0c\u5176\u5b9e\u5c31\u662f\u964d\u7ef4\u6253\u51fb\uff1a\u4efb\u4f55\u591a\u7ef4\u7684\u6570\u636e\u5bf9\u8c61\u90fd\u5fc5\u987b\u88ab\u964d\u7ef4\u6253\u51fb\u6210\u4e00\u7ef4\u624d\u80fd\u8fdb\u884c\u5b58\u50a8\u548c\u7f51\u7edc\u4f20\u8f93\u3002<\/p>\n\n\n\n<p>msgpack\u4e5f\u662f\u4e00\u4e2a\u964d\u7ef4\u6253\u51fb\uff0c\u54e6\u4e0d\uff0c\u5e8f\u5217\u5316\u7684\u624b\u6bb5\uff0c\u53ea\u4e0d\u8fc7\u5b83\u5e8f\u5217\u5316\u7684\u7ed3\u679c\u662f\u4e8c\u8fdb\u5236\u683c\u5f0f\u800c\u975ejson\u7684\u6587\u672c\u683c\u5f0f\uff0c\u4e0d\u7406\u89e3\u7684\u53ef\u4ee5\u7c7b\u6bd4http1.1\u548chttp2.0\uff0c\u5c31\u662f\u4e00\u4e2a\u7531\u6587\u672c\u683c\u5f0f\u8fdb\u5316\u5230\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<p>\u8fd9\u79cd\u8fdb\u5316\u6709\u4ec0\u4e48\u597d\u5904\u4ee5\u540e\u4e13\u95e8\u5199\u4e00\u7bc7\u6587\u7ae0\u8c08\u8c08\uff0c\u9898\u76ee\u6682\u5b9a\u300a\u4ece\u5b57\u7b26\u65f6\u4ee3\u5230\u4e8c\u8fdb\u5236\u65f6\u4ee3\u300b\u3002\u672c\u6587\u8c08\u8c08msgpack\u6709\u4ec0\u4e48\u597d\u5904\uff0c\u4e3a\u5565\u8bf4\u5b83\u80fd\u53d6\u4ee3json\uff1f<\/p>\n\n\n\n<p>\u9996\u5148\u6309\u5b98\u65b9\u7684\u8bdd\u8bf4\uff0cmsgpack\u6bd4json\u5c0f\uff0c\u6bd4json\u5feb\u3002\u6bd4json\u5c0f\u662f\u4e00\u5b9a\u7684\uff0c\u5b98\u7f51\u4e0a\u6709\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"513\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-1024x513.png\" alt=\"\" class=\"wp-image-15429\" style=\"width:468px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-1024x513.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-300x150.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-768x384.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-1536x769.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-830x415.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-230x115.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-350x175.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197-480x240.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-197.png 1894w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u4e0a\u9762\u90a3\u4e2ajson\u4e32\u5728utf8\u7f16\u7801\u4e0b\u6bcf\u4e2a\u5b57\u7b26\u4e00\u4e2a\u5b57\u8282\uff0c\u603b\u517127\u5b57\u8282\uff0c\u8f6c\u6362\u6210msgpack\u683c\u5f0f\u4e4b\u540e\u53ea\u5269\u4e0b18\u5b57\u8282\uff0c\u538b\u7f29\u4e86\u4e09\u5206\u4e4b\u4e00\u3002\u4e4b\u6240\u4ee5msgpack\u80fd\u591f\u538b\u7f29\u662f\u56e0\u4e3ajson\u4e32\u672c\u8eab\u6709\u8bb8\u591a\u6ca1\u7528\u7684\u4fe1\u606f\uff0c\u6bd4\u5982\u6bcf\u4e00\u4e2akey\u7684\u53cc\u5f15\u53f7\u5c31\u53ef\u4ee5\u7701\u53bb\uff0c\u7b80\u5355\u7684Boolean\u7c7b\u578b\u975e\u8981\u7528\u56db\u4e94\u4e2a\u5b57\u8282\u6765\u8868\u793a\uff08true\u548cfalse\uff09\u3002\u5f53\u7136XML\u7684\u6ca1\u7528\u4fe1\u606f\u5c31\u66f4\u591a\u4e86\uff0c\u8fd9\u4e9b\u90fd\u662f\u6587\u672c\u683c\u5f0f\u672c\u8eab\u7684\u5f0a\u7aef\uff0c\u4e8c\u8fdb\u5236\u683c\u5f0f\u5c31\u662f\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u7684\uff0c\u6bd4\u5982\u6570\u5b57\u5c31\u662f\u6570\u5b57\uff0c\u5c31\u5e94\u8be5\u7528\u4e8c\u8fdb\u5236\u8868\u793a\u3002<\/p>\n\n\n\n<p><strong>Msgpack\u662f\u5565\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u9996\u5148\uff0cMsgpack\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u4e8c\u8fdb\u5236\u5e8f\u5217\u5316\u683c\u5f0f\uff0c\u53ef\u4ee5\u628a\u5404\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u6bd4\u5982\u6570\u7ec4\u3001\u54c8\u5e0c\u8868\u4e4b\u7c7b\u7684\uff0c\u8f6c\u6362\u6210\u4e8c\u8fdb\u5236\u683c\u5f0f\u3002<\/p>\n\n\n\n<p>\u8fd9\u8ba9\u5b83\u53ef\u4ee5\u65b9\u4fbf\u5730\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6216\u5b58\u50a8\u5230\u6587\u4ef6\u91cc\u3002<\/p>\n\n\n\n<p>\u542c\u8d77\u6765\u662f\u4e0d\u662f\u548cJSON\u633a\u50cf\u7684\uff1f<\/p>\n\n\n\n<p>\u786e\u5b9e\uff0cMsgpack\u548cJSON\u90fd\u662f\u505a\u6570\u636e\u5e8f\u5217\u5316\u7684\u597d\u624b\uff0c\u4f46Msgpack\u662f\u7528\u7684\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u8fd9\u8ba9\u5b83\u5728\u5904\u7406\u901f\u5ea6\u548c\u6570\u636e\u5927\u5c0f\u4e0a\u90fd\u6709\u4e0d\u5c0f\u7684\u4f18\u52bf\u3002<\/p>\n\n\n\n<p>\u770b\u4e0bMsgpack\u4e0eJSON\u7684\u6027\u80fd\u5bf9\u6bd4\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"904\" height=\"516\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198.png\" alt=\"\" class=\"wp-image-15430\" style=\"width:488px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198.png 904w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-300x171.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-768x438.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-830x474.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-230x131.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-350x200.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/\u56fe\u7247-198-480x274.png 480w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n\n\n<p><strong>\u5e38\u89c1\u7528\u6cd5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Msgpack\u53ef\u4ee5\u7528\u5728\u591a\u79cd\u573a\u666f\uff0c\u5e38\u89c1\u7684\u6bd4\u5982\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u4f20\u8f93\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u5f97\u76ca\u4e8e\u5b83\u7684\u4e8c\u8fdb\u5236\u7279\u6027\uff0cMsgpack\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u901f\u5ea6\u5feb\uff0c\u751f\u6210\u7684\u6570\u636e\u5305\u4e5f\u66f4\u5c0f\u3002<\/p>\n\n\n\n<p>\u5bf9\u90a3\u4e9b\u5bf9\u6027\u80fd\u8981\u6c42\u6781\u9ad8\u7684\u5e94\u7528\u6765\u8bf4\uff0c\u7b80\u76f4\u662f\u6551\u661f\u3002<\/p>\n\n\n\n<p><strong>\u8fd8\u6709\uff0cMsgpack\u4e5f\u7ecf\u5e38\u88ab\u7528\u6765\u5b58\u50a8\u65e5\u5fd7<\/strong><\/p>\n\n\n\n<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u6bcf\u5929\u8981\u5904\u7406\u6210\u5343\u4e0a\u4e07\u7684\u8bf7\u6c42\uff0c\u7528JSON\u6765\u5b58\u50a8\u65e5\u5fd7\uff0c\u6587\u4ef6\u53ef\u80fd\u4f1a\u975e\u5e38\u5927\u3002<\/p>\n\n\n\n<p>\u4f46\u5982\u679c\u6362\u6210Msgpack\uff0c\u5c31\u80fd\u5927\u5e45\u5ea6\u51cf\u5c11\u5b58\u50a8\u7a7a\u95f4\u7684\u5360\u7528\uff0c\u540c\u65f6\u4e5f\u4fbf\u4e8e\u540e\u7eed\u7684\u6570\u636e\u5206\u6790\u3002<\/p>\n\n\n\n<p>Msgpack\u7684\u539f\u7406 \u90a3Msgpack\u662f\u600e\u4e48\u505a\u5230\u8fd9\u4e48\u9ad8\u6548\u7684\u5462\uff1f\u4e3b\u8981\u662f\u51e0\u70b9\uff1a<\/p>\n\n\n\n<ol>\n<li>\u4e8c\u8fdb\u5236\u683c\u5f0f\uff1a\u4f7f\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\u6765\u8868\u793a\u6570\u636e\uff0c\u6bd4JSON\u7684\u6587\u672c\u683c\u5f0f\u66f4\u7d27\u51d1\uff0c\u81ea\u7136\u5c31\u51cf\u5c11\u4e86\u6570\u636e\u4f53\u79ef\u3002<\/li>\n\n\n\n<li>\u7c7b\u578b\u5171\u4eab\uff1a\u5728Msgpack\u4e2d\uff0c\u76f8\u540c\u6570\u636e\u7ed3\u6784\u7684\u4e0d\u540c\u5b9e\u4f8b\u53ef\u4ee5\u5171\u4eab\u7c7b\u578b\u4fe1\u606f\uff0c\u907f\u514d\u4e86\u91cd\u590d\u7684\u7c7b\u578b\u5b9a\u4e49\uff0c\u6570\u636e\u5927\u5c0f\u4e5f\u56e0\u6b64\u51cf\u5c11\u3002<\/li>\n\n\n\n<li>\u65e0\u9700\u5f15\u53f7\uff1a\u5728Msgpack\u91cc\uff0c\u5b57\u7b26\u4e32\u548c\u4e8c\u8fdb\u5236\u6570\u636e\u4e0d\u9700\u8981\u7528\u5f15\u53f7\u5305\u56f4\uff0c\u8fd9\u4e5f\u8282\u7701\u4e86\u4e00\u4e9b\u7a7a\u95f4\u3002<\/li>\n\n\n\n<li>\u6269\u5c55\u7c7b\u578b\uff1aMsgpack\u8fd8\u652f\u6301\u6269\u5c55\u7c7b\u578b\uff0c\u8ba9\u4f60\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6570\u636e\u7c7b\u578b\uff0c\u8ba9\u6570\u636e\u8868\u793a\u66f4\u7075\u6d3b\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>\u4e0eJSON\u7684\u6bd4\u8f83<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u6bd4\u8d77JSON\uff0cMsgpack\u5728\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u7684\u901f\u5ea6\u901a\u5e38\u66f4\u5feb\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u65f6\u3002<\/p>\n\n\n\n<p>\u7531\u4e8e\u662f\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u751f\u6210\u7684\u6570\u636e\u5305\u4e5f\u901a\u5e38\u6bd4JSON\u5c0f\uff0c\u8fd9\u5728\u7f51\u7edc\u4f20\u8f93\u548c\u5b58\u50a8\u4e0a\u90fd\u6709\u4f18\u52bf\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\uff0cJSON\u7684\u6587\u672c\u683c\u5f0f\u66f4\u6613\u4e8e\u4eba\u9605\u8bfb\u548c\u7f16\u8f91\uff0c\u800cMsgpack\u5219\u9700\u8981\u4e13\u95e8\u7684\u5de5\u5177\u6765\u5904\u7406\u3002<\/p>\n\n\n\n<p><strong>Java\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e0b\u9762\uff0c\u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u5728\u5927\u5bb6\u5e38\u7528\u7684Springboot\u9879\u76ee\u4e2d\uff0c\u8be5\u5982\u4f55\u4f7f\u7528Msgpack\uff1a<\/p>\n\n\n\n<p><strong>\u5f15\u5165\u4f9d\u8d56<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;dependencies>\n    &lt;!-- Spring Boot Starter Web -->\n    &lt;dependency>\n        &lt;groupId>org.springframework.boot&lt;\/groupId>\n        &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>\n    &lt;\/dependency>\n\n    &lt;!-- Msgpack Dependency -->\n    &lt;dependency>\n        &lt;groupId>org.msgpack&lt;\/groupId>\n        &lt;artifactId>msgpack&lt;\/artifactId>\n        &lt;version>0.9.1&lt;\/version> &lt;!-- \u7248\u672c\u53f7\u53ef\u80fd\u4f1a\u6709\u53d8\u5316\uff0c\u8bf7\u786e\u4fdd\u4f7f\u7528\u6700\u65b0\u7248\u672c -->\n    &lt;\/dependency>\n&lt;\/dependencies>\n<\/pre>\n\n\n\n<p><strong>\u4f7f\u7528Msgpack\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/strong><\/p>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2aController\u6765\u5904\u7406HTTP\u8bf7\u6c42\uff0c\u5e76\u4f7f\u7528Msgpack\u6765\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u5bf9\u8c61\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import org.msgpack.MessagePack;\nimport org.springframework.web.bind.annotation.*;\n\n@RestController\n@RequestMapping(\"\/api\")\npublic class MyController {\n\n    @PostMapping(\"\/serialize\")\n    public byte[] serialize(@RequestBody MyObject myObject) throws Exception {\n        MessagePack msgpack = new MessagePack();\n        return msgpack.write(myObject);\n    }\n\n    @PostMapping(\"\/deserialize\")\n    public MyObject deserialize(@RequestBody byte[] bytes) throws Exception {\n        MessagePack msgpack = new MessagePack();\n        return msgpack.read(bytes, MyObject.class);\n    }\n}<\/pre>\n\n\n\n<p>MyObject\u662f\u4e00\u4e2a\u7b80\u5355\u7684POJO\u7c7b\uff0c\u5b83\u5c06\u88abMsgpack\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class MyObject {\n    private String name;\n    private int age;\n\n    \/\/ Getters and setters\n}<\/pre>\n\n\n\n<p><strong>\u6d4b\u8bd5\u7ed3\u679c\uff1a<\/strong><\/p>\n\n\n\n<p>\u6700\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u53d1\u9001HTTP\u8bf7\u6c42\u6765\u6d4b\u8bd5\u8fd9\u4e2aController\u3002<br>\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528curl\u6765\u53d1\u9001POST\u8bf7\u6c42\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Serialize\ncurl -X POST -H \"Content-Type: application\/json\" -d '{\"name\":\"John\",\"age\":30}' http:\/\/localhost:8080\/api\/serialize\n\n# Deserialize\ncurl -X POST -H \"Content-Type: application\/json\" -d '{\"bytes\":[...]}' http:\/\/localhost:8080\/api\/deserialize<\/pre>\n\n\n\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u597d\u4e86\uff0c\u670b\u53cb\u4eec\uff0c\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5e2e\u4f60\u4e86\u89e3\u4e86Msgpack\u2014\u2014\u4e00\u4e2a\u9ad8\u6548\u3001\u7d27\u51d1\u7684\u6570\u636e\u5e8f\u5217\u5316\u5de5\u5177\u3002<\/p>\n\n\n\n<p>\u65e2\u7136msgpack\u6bd4json\u53c8\u5c0f\u53c8\u5feb\uff0cjson\u771f\u7684\u4e00\u65e0\u662f\u5904\u5417\uff1f\u867d\u7136\u5728\u7f51\u7edc\u4f20\u8f93\u7684\u5e94\u7528\u573a\u666f\u4e0amsgpack\u53ef\u4ee5\u5b8c\u80dcjson\uff0c\u53ef\u4f5c\u4e3a\u914d\u7f6e\u6587\u4ef6\u7684\u573a\u666f\u4e0a\u53c8\u5982\u4f55\u5462\uff1f\u6211\u4eec\u77e5\u9053JSON\u683c\u5f0f\u5bf9\u7528\u6237\u662f\u5f88\u53cb\u597d\u7684\uff0c\u53ef\u8bfb\u6027\u975e\u5e38\u5f3a\uff0c\u5728\u7f16\u8f91\u5668\u4e2d\u4ee3\u7801\u6298\u53e0\uff0c\u7c7b\u578b\u9ad8\u4eae\u90fd\u975e\u5e38\u65b9\u4fbf\u3002msgpack\u4f5c\u4e3a\u4e8c\u8fdb\u5236\u683c\u5f0f\u4f3c\u4e4e\u4e0d\u597d\u76f4\u63a5\u7f16\u8f91\u3002<\/p>\n\n\n\n<p>\u867d\u7136\u5b83\u7684\u53ef\u8bfb\u6027\u4e0d\u5982JSON\uff0c\u4f46\u5728\u5f88\u591a\u573a\u5408\uff0c\u5b83\u7684\u6027\u80fd\u4f18\u52bf\u8db3\u4ee5\u5f25\u8865\u8fd9\u70b9\u5c0f\u7f3a\u9677\u3002<br>\u5982\u679c\u4f60\u5bf9\u81ea\u5df1\u9879\u76ee\u7684\u6027\u80fd\u6709\u7740\u6781\u81f4\u7684\u8ffd\u6c42\uff0c\u5e0c\u671b\u4f60\u80fd\u5728\u9879\u76ee\u4e2d\u5c1d\u8bd5\u4f7f\u7528Msgpack\uff0c\u9009\u5bf9\u5de5\u5177\uff0c\u4e8b\u534a\u529f\u500d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u54b1\u4eec\u804a\u804a\u4e00\u4e2a\u633a\u9177\u7684\u6570\u636e\u5e8f\u5217\u5316\u5de5\u5177\u2014\u2014Msgpack\u3002 \u4f60\u53ef\u80fd\u542c\u8fc7JSON\uff0c\u5b83\u5728\u6570\u636e\u4ea4\u6362\u9886\u57df\u53ef\u8c13\u662f\u8d85\u7ea7\u660e\u661f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/15428"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15428"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/15428\/revisions"}],"predecessor-version":[{"id":15432,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/15428\/revisions\/15432"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}