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

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

问题描述

我刚开始使用MongoDB,我注意到的一件事是它使用 BSON 进行存储内部数据.但是,关于BSON是什么以及在MongoDB中如何使用BSON的文档尚不清楚.有人可以给我解释一下吗?

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的文档的二进制编码将文档存储在集合中.它增加了对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天全站免登陆