什么是 BSON,它与 JSON 究竟有何不同? [英] What is BSON and exactly how is it different from JSON?

查看:21
本文介绍了什么是 BSON,它与 JSON 究竟有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 MongoDB,我注意到的一件事是它使用 BSON 来存储内部数据.然而,文档并不清楚 BSON 是什么以及它在 MongoDB 中的使用方式.谁能给我解释一下?

I am just starting out with MongoDB and one of the things that I have noticed is that it uses BSON to store data internally. However the documentation is not exactly clear on what BSON is and how it is used in MongoDB. Can someone explain it to me, please?

推荐答案

BSON 是 MongoDB 在当将文档存储在集合中.它增加了对 JSON 中不支持的数据类型(如日期和二进制)的支持.

BSON is the binary encoding of JSON-like documents that MongoDB uses when storing documents in collections. It adds support for data types like Date and binary that aren't supported in JSON.

实际上,在使用 MongoDB 时,您不必对 BSON 了解太多,您只需要在构建文档时使用您的语言的本机类型及其驱动程序提供的类型(例如 ObjectId),它们将是由驱动程序映射到适当的 BSON 类型.

In practice, you don't have to know much about BSON when working with MongoDB, you just need to use the native types of your language and the supplied types (e.g. ObjectId) of its driver when constructing documents and they will be mapped into the appropriate BSON type by the driver.

这篇关于什么是 BSON,它与 JSON 究竟有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆