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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • int8 int16 int32 int64 float16 float32

    int8 int16 int32 int64 float16 float32int8取值范围是-128-127Int16意思是16位整数(16bitinteger),相当于short占2个字节-32768~32767Int32意思是32位整数(32bitinteger),相当于int占4个字节-2147483648~2147483647Int64意思是64位整数(64bitinterger),相当于longlong占8个字节-9223372036854775808~92233720368547

    2022年8月15日
    1
  • HTTP.sys远程代码执行漏洞修复

    HTTP.sys远程代码执行漏洞修复1.漏洞描述Http.sys是MicrosoftWindows处理HTTP请求的内核驱动程序。HTTP.sys会错误解析某些特殊构造的HTTP请求,导致远程代码执行漏洞。成功利用此漏洞后,攻击者可在System帐户上下文中执行任意代码。由于此漏洞存在于内核驱动程序中,攻击者也可以远程导致操作系统蓝屏。此次受影响的系统中,Windows7、Windows8、WindowsServer2008R2和WindowsServer2012所带的HTTP.sys驱动均存在一个远程代码执行漏洞,远程攻击者可以通

    2022年7月18日
    14
  • BigDecimal加减乘除计算

    前阵子做题遇到了大数的精确计算,再次认识了bigdecimal关于Bigdecimal意外的有许多小知识点和坑,这里特此整理一下为方便以后学习,希望能帮助到其他的萌新BigDecimal的运算——加减乘除首先是bigdecimal的初始化这里对比了两种形式,第一种直接value写数字的值,第二种用string来表示BigDecimalnum1=new…

    2022年4月7日
    235
  • 红帽linux忘记密码的时候

    红帽linux忘记密码的时候

    2021年8月28日
    75
  • oracle 解锁表

    oracle 解锁表操作的前提用sys用户以SYSDBA角色登录第一种解锁方式1.查询被锁的表selectobject_name,machine,s.sid,s.serial#fromv$locked_objectl,dba_objectso,v$sessionswherel.object_id = o.object_idandl.session_id=s.sid;2.查询…

    2022年6月15日
    29
  • 利用serv-u创建ftp服务器_ftp读取目录列表失败

    利用serv-u创建ftp服务器_ftp读取目录列表失败一、由来最近改写了项目中ftp上传部分的代码。用到的组件为:<dependency><groupId>commons-net</groupId><artifactId>commons-net</artifactId><version>3.3</version></depen…

    2022年9月11日
    0

发表回复

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

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