{"id":247338,"date":"2024-01-02T20:40:28","date_gmt":"2024-01-02T12:40:28","guid":{"rendered":"https:\/\/www.idc.net\/help\/247338\/"},"modified":"2024-01-02T20:40:28","modified_gmt":"2024-01-02T12:40:28","slug":"mongodb-%e6%9c%af%e8%af%ad-bson","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/247338\/","title":{"rendered":"MongoDB \u672f\u8bed &#8211; BSON"},"content":{"rendered":"<p><title id=\"mongodb-%e6%9c%af%e8%af%ad-bson-jaulGzyOFe\">MongoDB \u672f\u8bed - BSON<\/title><\/p>\n<h1 id=\"mongodb-%e6%9c%af%e8%af%ad-bson-jaulGzyOFe\">MongoDB \u672f\u8bed - BSON<\/h1>\n<p>MongoDB \u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90\u6587\u6863\u6570\u636e\u5e93\uff0c\u5b83\u4f7f\u7528 BSON\uff08Binary JSON\uff09\u4f5c\u4e3a\u5176\u6570\u636e\u5b58\u50a8\u548c\u4ea4\u6362\u683c\u5f0f\u3002BSON \u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\uff0c\u7c7b\u4f3c\u4e8e JSON\uff0c\u4f46\u5177\u6709\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\u548c\u529f\u80fd\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u4e86\u89e3 BSON \u7684\u7279\u70b9\u548c\u7528\u6cd5\u3002<\/p>\n<h2 id=\"bson-%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f-jaulGzyOFe\">BSON \u662f\u4ec0\u4e48\uff1f<\/h2>\n<p>BSON \u662f Binary JSON \u7684\u7f29\u5199\uff0c\u5b83\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\uff0c\u7528\u4e8e\u5b58\u50a8\u548c\u4ea4\u6362 MongoDB \u4e2d\u7684\u6570\u636e\u3002BSON \u7c7b\u4f3c\u4e8e JSON\uff0c\u4f46\u5177\u6709\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\u548c\u529f\u80fd\u3002\u4e0e JSON \u76f8\u6bd4\uff0cBSON \u7684\u4e3b\u8981\u4f18\u52bf\u662f\u5b83\u7684\u7d27\u51d1\u6027\u548c\u9ad8\u6548\u6027\u3002\u7531\u4e8e BSON \u662f\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u5b83\u53ef\u4ee5\u66f4\u5feb\u5730\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u4e86 MongoDB \u7684\u6027\u80fd\u3002<\/p>\n<h2 id=\"bson-%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b-jaulGzyOFe\">BSON \u6570\u636e\u7c7b\u578b<\/h2>\n<p>BSON \u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u57fa\u672c\u6570\u636e\u7c7b\u578b\u548c\u590d\u6742\u6570\u636e\u7c7b\u578b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 BSON \u6570\u636e\u7c7b\u578b\uff1a<\/p>\n<ul>\n<li><strong>Double<\/strong> - \u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570<\/li>\n<li><strong>String<\/strong> - \u5b57\u7b26\u4e32<\/li>\n<li><strong>Boolean<\/strong> - \u5e03\u5c14\u503c<\/li>\n<li><strong>Array<\/strong> - \u6570\u7ec4<\/li>\n<li><strong>Object<\/strong> - \u5bf9\u8c61<\/li>\n<li><strong>Null<\/strong> - \u7a7a\u503c<\/li>\n<li><strong>Int32<\/strong> - 32 \u4f4d\u6574\u6570<\/li>\n<li><strong>Int64<\/strong> - 64 \u4f4d\u6574\u6570<\/li>\n<li><strong>Timestamp<\/strong> - \u65f6\u95f4\u6233<\/li>\n<li><strong>Binary<\/strong> - \u4e8c\u8fdb\u5236\u6570\u636e<\/li>\n<li><strong>ObjectId<\/strong> - \u6587\u6863 ID<\/li>\n<li><strong>RegularExpression<\/strong> - \u6b63\u5219\u8868\u8fbe\u5f0f<\/li>\n<li><strong>JavaScript<\/strong> - JavaScript \u4ee3\u7801<\/li>\n<li><strong>Symbol<\/strong> - \u7b26\u53f7<\/li>\n<li><strong>DateTime<\/strong> - \u65e5\u671f\u65f6\u95f4<\/li>\n<\/ul>\n<h2 id=\"bson-%e4%b8%8e-json-%e7%9a%84%e5%8c%ba%e5%88%ab-jaulGzyOFe\">BSON \u4e0e JSON \u7684\u533a\u522b<\/h2>\n<p>\u867d\u7136 BSON \u548c JSON \u975e\u5e38\u76f8\u4f3c\uff0c\u4f46\u5b83\u4eec\u4e4b\u95f4\u5b58\u5728\u4e00\u4e9b\u533a\u522b\u3002\u4ee5\u4e0b\u662f BSON \u548c JSON \u7684\u4e3b\u8981\u533a\u522b\uff1a<\/p>\n<ul>\n<li>BSON \u652f\u6301\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5982\u65e5\u671f\u65f6\u95f4\u3001\u4e8c\u8fdb\u5236\u6570\u636e\u548c\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/li>\n<li>BSON \u662f\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u800c JSON \u662f\u6587\u672c\u683c\u5f0f\u3002<\/li>\n<li>BSON \u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u64cd\u4f5c\u3002<\/li>\n<li>BSON \u652f\u6301\u5d4c\u5957\u6587\u6863\u548c\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%9c%a8-mongodb-%e4%b8%ad%e4%bd%bf%e7%94%a8-bson-jaulGzyOFe\">\u5728 MongoDB \u4e2d\u4f7f\u7528 BSON<\/h2>\n<p>\u5728 MongoDB \u4e2d\uff0cBSON \u662f\u9ed8\u8ba4\u7684\u6570\u636e\u5b58\u50a8\u548c\u4ea4\u6362\u683c\u5f0f\u3002\u5f53\u6211\u4eec\u5c06\u6570\u636e\u63d2\u5165\u5230 MongoDB \u4e2d\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u5c06\u6570\u636e\u8f6c\u6362\u4e3a BSON \u683c\u5f0f\u8fdb\u884c\u5b58\u50a8\u3002\u540c\u6837\u5730\uff0c\u5f53\u6211\u4eec\u4ece MongoDB \u4e2d\u68c0\u7d22\u6570\u636e\u65f6\uff0c\u5b83\u4f1a\u5c06 BSON \u6570\u636e\u8f6c\u6362\u4e3a\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\uff0c\u5982 JSON\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5728 MongoDB \u4e2d\u4f7f\u7528 BSON\uff1a<\/p>\n<pre><code>db.users.insertOne({\n  \"name\": \"John Doe\",\n  \"age\": 30,\n  \"email\": \"john@example.com\"\n});\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 JSON \u683c\u5f0f\u63d2\u5165\u4e86\u4e00\u4e2a\u6587\u6863\u3002MongoDB \u4f1a\u81ea\u52a8\u5c06\u5176\u8f6c\u6362\u4e3a BSON \u683c\u5f0f\u8fdb\u884c\u5b58\u50a8\u3002<\/p>\n<h2 id=\"%e7%bb%93%e8%ae%ba-jaulGzyOFe\">\u7ed3\u8bba<\/h2>\n<p>BSON \u662f MongoDB \u4e2d\u7684\u672f\u8bed\uff0c\u5b83\u662f\u4e00\u79cd\u4e8c\u8fdb\u5236\u8868\u793a\u5f62\u5f0f\uff0c\u7528\u4e8e\u5b58\u50a8\u548c\u4ea4\u6362\u6570\u636e\u3002BSON \u7c7b\u4f3c\u4e8e JSON\uff0c\u4f46\u5177\u6709\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\u548c\u529f\u80fd\u3002\u901a\u8fc7\u4f7f\u7528 BSON\uff0cMongoDB \u53ef\u4ee5\u63d0\u4f9b\u66f4\u9ad8\u6548\u7684\u6570\u636e\u5b58\u50a8\u548c\u4ea4\u6362\u673a\u5236\u3002\u4e86\u89e3 BSON \u7684\u7279\u70b9\u548c\u7528\u6cd5\u5bf9\u4e8e\u5f00\u53d1\u4eba\u5458\u6765\u8bf4\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u5b83\u662f\u4e0e MongoDB \u4ea4\u4e92\u7684\u57fa\u7840\u3002<\/p>\n<h3 id=\"%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%a6%96%e9%80%89%e5%90%8e%e6%b5%aa%e4%ba%91-jaulGzyOFe\">\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u63d0\u4f9b\u5546\uff0c\u540e\u6d6a\u4e91\u662f\u60a8\u7684\u9996\u9009\u3002\u540e\u6d6a\u4e91\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u4ee5\u6ee1\u8db3\u60a8\u7684\u5404\u79cd\u9700\u6c42\u3002\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684<a href=\"https:\/\/idc.net\">\u5b98\u7f51<\/a>\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB \u672f\u8bed - BSON MongoDB \u672f\u8bed - BSON MongoDB \u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90\u6587\u6863\u6570 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-247338","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/247338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=247338"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/247338\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=247338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=247338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=247338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}