Bson「建议收藏」

Bson

大家好,又见面了,我是全栈君。

https://en.wikipedia.org/wiki/BSON

BSON /ˈbsɒn/ is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database.

It is a binary form for representing simple data structuresassociative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB.

The name “BSON” is based on the term JSON and stands for “Binary JSON”.

 

数据类型和语法:

BSON documents (objects) consist of an ordered list of elements.

Each element consists of a field name, a type, and a value. Field names are strings.

Types include:

  • string
  • integer (32- or 64-bit)
  • double (64-bit IEEE 754 floating point number)
  • date (integer number of milliseconds since the Unix epoch)
  • byte array (binary data)
  • boolean (true and false)
  • null
  • BSON object
  • BSON array
  • Javascript Code
  • MD5 Binary Data
  • Regular Expression

BSON types are nominally a superset of JSON types (JSON does not have a date or a byte array type, for example[3]), with one exception of not having a universal “number” type as JSON does.

 

 

效率

Compared to JSON, BSON is designed to be efficient both in storage space and scan-speed.

Large elements in a BSON document are prefixed with a length field to facilitate促进 scanning.

In some cases, BSON will use more space than JSON due to the length prefixes and explicit array indices.

 

范例

A document such as {“hello”:”world”} will be stored as:

Bson: \x16\x00\x00\x00 // total document size \x02 // 0x02 = type String hello\x00 // field name \x06\x00\x00\x00world\x00 // field value (size of value, value, null terminator) \x00 // 0x00 = type EOO ('end of object')

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/108845.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Sql Prompt 10激活成功教程[通俗易懂]

    Sql Prompt 10激活成功教程[通俗易懂]1.下载安装文件待审核…2.激活成功教程修改hosts文件(如若跳过此步骤,虽然可以激活成功教程成功,但是重启电脑之后,又得重新激活成功教程)首先系统HOSTS文件添加以下屏蔽网络HOSTS路径:C:\Windows\System32\drivers\etc127.0.0.1red-gate.com127.0.0.1www.red-gate.com127.0.0.1licensing.red-gate.com127.0.0.1productlogin.red-ga…

    2022年7月26日
    103
  • Network 之二 Ethernet(以太网)中的 MAC、MII、PHY 详解[通俗易懂]

    Network 之二 Ethernet(以太网)中的 MAC、MII、PHY 详解[通俗易懂]结构  从硬件的角度看,以太网接口电路主要由MAC(MediaAccessControl)控制器和物理层接口PHY(PhysicalLayer,PHY)两大部分构成。如下图所示  但是,在实际的设计中,以上三部分并不一定独立分开的。由于,PHY整合了大量模拟硬件,而MAC是典型的全数字器件。考虑到芯片面积及模拟/数字混合架构的原因,通常,将MAC集成进微控制器而将PHY留在片外…

    2022年9月22日
    0
  • memset库函数「建议收藏」

    memset库函数「建议收藏」头文件:#include定义函数:void*memset(void*s,intc,size_tn);函数说明:memset()会将参数s所指的内存区域前n个字节以参数c填入,然后

    2022年8月5日
    7
  • sublime GOPATH 设置

    sublime GOPATH 设置

    2021年8月25日
    65
  • mysql5.7卸载不干净_mysql卸载残留

    mysql5.7卸载不干净_mysql卸载残留一、在控制面板中卸载mysql软件,此时mysql没有卸载干净。二、卸载过后删除C:ProgramFiles(x86)MySQL该目录下剩余了所有文件,把mysql文件夹也删了三、windows+R运行“regedit”文件,打开注册表四、删除注册表:HKEY_LOCAL_MACHINESYSTEMControlSet001ServicesEventlogApplicationMySQL文件夹…

    2022年9月28日
    0
  • idea替换区分大小写[通俗易懂]

    idea替换区分大小写[通俗易懂]

    2022年9月28日
    1

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号