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

BSON /ˈbiːsɒ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')

Bson的更多相关文章

  1. ASP.NET Web API 2.1支持Binary JSON(Bson)

    ASP.NET Web API 2.1内建支持XML.Json.Bson.form-urlencoded的MiME type,今天重点介绍下Bson.BSON是由10gen开发的一个数据格式,目前主要 ...

  2. MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)

    一.Windows 下载安装 1.去http://www.mongodb.org/downloads下载,mongodb默认安装在C:\Program Files\MongoDB目录下,到F:\Off ...

  3. BSON 1.0版本规范(翻译)

    BSON 1.0版本规范 本文翻译自 http://bsonspec.org/spec.html BSON是用于存储零个或多个键/值对为一个单一的实体的一个二进制格式.我们称这个实体为文档(Docum ...

  4. nginx安装过程,报错处理:make[1]: *** [objs/addon/src/bson.o] Error 1

    nginx安装过程中,经常会有各种错误: 具体安装步骤这里不做说明,网上一搜大把: 主要分析安装过程中遇到的问题 在make编译的时候,若报如下错误: cc1: warnings being trea ...

  5. MongoDB之bson的介绍

    MongoDB之bson的介绍 1. 什么是bson BSON是一种类json的一种二进制形式的存储格式,简称Binary JSON,它和JSON一样,支持内嵌的文档对象和数组对象,但是BSON有JS ...

  6. MongoDB之一介绍(MongoDB与MySQL的区别、BSON与JSON的区别)

    MySQL与MongoDB的操作对比,以及区别 MySQL与MongoDB都是开源的常用数据库,但是MySQL是传统的关系型数据库,MongoDB则是非关系型数据库,也叫文档型数据库,是一种NoSQL ...

  7. BSON与JSON的区别

    BSON是由10gen开发的一个数据格式,目前主要用于MongoDB中,是MongoDB的数据存储格式.BSON基于JSON格式,选择JSON进行改造的原因主要是JSON的通用性及JSON的schem ...

  8. MongoDB - Introduction to MongoDB, BSON Types

    BSON is a binary serialization format used to store documents and make remote procedure calls in Mon ...

  9. 什么是JSON?如何使用?它比BSON更好吗?

    本文由码农网 – 小峰原创翻译,转载请看清文末的转载要求,欢迎参与我们的付费投稿计划! 长话短说:如果你想知道JSON——它是什么,如何使用它以及它和BSON哪个更好,那么你来对地方了.在本文中,我们 ...

随机推荐

  1. 解决windows的控制台显示utf8乱码的问题

    在控制台的属性里 修改自体为: 新宋体 在控制台下执行命令: chcp 65001

  2. Java中main方面面试题

    1.不用main方法如何定义一个类? 不行,没有main方法我们不能运行Java类. 在Java 7之前,你可以通过使用静态初始化运行Java类.但是,从Java 7开始就行不通了. 2.main() ...

  3. HTML data属性简介以及低版本浏览器兼容算法

    实例 使用 data-* 属性来嵌入自定义数据: <ul> <li data-animal-type="bird">Owl</li> <l ...

  4. xml、 Dao service 三层参数以及对应关系

    =======service   调用dao用params.put(K,Value);将参数传入后台. BaseResponse response = new BaseResponse(); Map& ...

  5. 使用Mysql ID自增长时 在Mapper的<insert>里添加对应的代码

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long&quo ...

  6. Java的多线程+Socket 后台 Ver 2.0

    package com.wulala; import java.io.IOException;import java.net.ServerSocket;import java.net.Socket; ...

  7. OSAL

    1. CC254x的软件基于OSAL架构 2. OSAL并非一个真的操作系统, 而只是让软件设立一个事件的执行方法(setup excution of events) 3. 每一个子系统都在OSAL的 ...

  8. linux的mtd架构分析【转】

    转自:http://blog.csdn.net/column/details/xgbing-linux-mtd.html linux mtd 嵌入式系统的存储有很多不可靠之处.随着使用容量的增大,现在 ...

  9. vm克隆虚拟机网络配置

    *CentOS虚拟机网络连接方式为:桥接模式* 虚拟机克隆后会导致网络连接不上:(引起原因是新的MAC和网卡配置对应不上)问题解决(在克隆机里执行下列步骤): vi /etc/udev/rules.d ...

  10. JDK结构介绍

    dt.jar和tools.jar位于:{Java_Home}/lib/下, 而rt.jar位于:{Java_Home}/jre/lib/下, 其中: (1) rt.jar是JAVA基础类库,也就是你在 ...