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


相关推荐

  • Flake8_quakemaker

    Flake8_quakemakerFlake8简介转载自:http://www.malike.net.cn/blog/2013/10/23/flake8-tutorial/| COMMENTSFlake8包装了下列工具:PyFlakes:静态检查Python代码逻辑错误的工具。pep8:静态检查PEP8编码风格的工具。NedBatchelder’sMcCabescript:静态

    2025年11月10日
    2
  • docker 导入导出镜像_docker拉取镜像到本地

    docker 导入导出镜像_docker拉取镜像到本地docker导入导出镜像文件:把某个docker镜像保存到本地文件,命令如下dockersave-o镜像名.tar原始镜像名(REPOSITORY项)导出$dockersave-o/root/images/jenkins_image.tarjenkins/jenkins:latest导入$dockerload</root/images/jenkins_image.tar导出镜像如果要存出镜像到本地文件,可以使用dockersave命令。例如,存出本地的ubu

    2025年9月17日
    10
  • 回归分析中自变量取舍、检验及多重共线性处理(VIF)「建议收藏」

    回归分析中自变量取舍、检验及多重共线性处理(VIF)「建议收藏」A1正交假定:误差项矩阵与X中每一个x向量都不相关高斯-马尔科夫定理:若满足A1和A2假定,则采用最小二乘法得到回归参数估计是最佳线性无偏估计方程估计值b1和b2可以看做偏回归系数,也是相应自变量对y的一种偏效应偏效应:在控制变量下,各自变量X对因变量Y的净效应残差项:针对具体模型而言,被定义为样本回归模型中观测值与预测值之差误差项:针对总体真实回归模型而言,它由一些不可观测因素或测量…

    2022年5月30日
    66
  • yarn的安装和使用(yarn安装mysql)

    升级yarn升级指定版本(例:升级到v1.22.10版本)yarnupgradev1.22.10npmyarn安装/升级最新版本npminstallyarn@latest-g查看yarn历史版本npmviewyarnversions–json[“0.1.0″,”0.1.1″,”0.1.2″,”0.1.3″,”0.15.1″,”0.16.0″,”0.16.1″,”0.17.0”,”0.17…

    2022年4月13日
    69
  • 数据结构的堆排序_数据结构冒泡排序算法

    数据结构的堆排序_数据结构冒泡排序算法一、什么是堆排序1.堆,堆排序对于“堆”我们可以理解为具有以下性质的完全二叉树:每个结点的值都大于或等于其左右孩子结点的值,称为大顶堆每个结点的值都小于或等于其左右孩子结点的值,称为小顶堆堆

    2022年8月16日
    5
  • 一款强大的网站在线客服聊天系统:whisper搭建教程

    一款强大的网站在线客服聊天系统:whisper搭建教程简介whisper是一个在线客服系统源码,采用thinkphp5+Gatewayworker编写,性能强悍。自己搭建,控制在自己,也无需为您的数据安全担心,您可以应用在任何的正规的网站,只需要添加一段简单的js代码,就可以使您的网站拥有在线客服功能。官方网站:http://whisper.baiyf.com/截图功能支持客服分组,多客服服务,让您的服务更有条理。 支持客服…

    2022年7月19日
    30

发表回复

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

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