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')

 

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Winform技巧:TreeView导入Excel

    Winform技巧:TreeView导入Excel

  • Scala Hello 示例

    Scala Hello 示例

    2021年12月17日
  • 【Javascript】【WebRTC】WebRTC从原理到实现(四):ICE服务器

    【Javascript】【WebRTC】WebRTC从原理到实现(四):ICE服务器ICE全称InteractiveConnectivityEstablishment,翻译成中文就是“交互式连通建立方式”它通过综合利用现有STUN,TURN等协议,有效地穿透各种NAT,以更有效的方式来建立会话…

  • PLSQL developer使用技巧「建议收藏」

    PLSQL developer使用技巧「建议收藏」1.调整字体PLSQLDeveloper的默认字体是大小是小五,看起来比较小。我们可以通过以下方式将字体改编为五号字体。工具-首选项-用户界面-字体-浏览器(编辑器、表格)-选择-大小五号。2.文本替换文本替换可以极大提高我们敲写SQL的效率。替换方式如下:工具-首选项-用户界面-编辑器-自动替换-选择文件如下,提供一个简单的模板。sf

  • Android之ViewStub的简单使用

    Android之ViewStub的简单使用1.viewstub就是动态加载试图;也就是在我们的app启动绘制页面的时候,他不会绘制到view树中;当在代码中执行inflate操作后,她才会被添加到试图中。其实ViewStub就是一个宽高都为0的一个View,它默认是不可见的,只有通过调用setVisibility函数或者Inflate函数才会将其要装载的目标布局给加载出来,从而达到延迟加载的效果,这个要被加载的布局通过android:l…

  • Eclipse和JDK安装教程(22年8月)[通俗易懂]

    Eclipse和JDK安装教程(22年8月)[通俗易懂]初次学习,安装软件会耗费许多时间。这很不值得,我们可以做更多别的事情。不妨试试这篇简单的帖子,希望节省你的宝贵时间。第一次顺利,以后安装就轻车熟路,这就是好的开始。

发表回复

您的电子邮箱地址不会被公开。

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