Bson「建议收藏」

Bson

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

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


相关推荐

  • vector的几种初始化及赋值方式

    vector的几种初始化及赋值方式vector的几种初始化及赋值方式

    2022年7月18日
  • java专业是什么专业,写的太详细了「建议收藏」

    java专业是什么专业,写的太详细了「建议收藏」前言SQL语句执行慢的原因是面试中经常会被问到的,对于服务端开发来说也是必须要关注的问题。在生产环境中,SQL执行慢是很严重的事件。那么如何定位慢SQL、慢的原因及如何防患于未然。接下来带着这些问题让我们开启本期之旅!第1章:Dubbo的简史、后续的规划和整体架构大图————Dubbo高性能RPC通信框架1.1应用架构演进过程1.2Dubbo简介1.3Dubbo总体大图第2章:Dubbo的环境配置和基于Dubbo开发第一款应用程序————开发第一款Dubbo应用程序

    2022年7月7日
  • springcloud gateway作用_gateway网关路由配置

    springcloud gateway作用_gateway网关路由配置Gateway服务网关在SpringCloud中网关的实现包括两种:①gateway②zuulzuul是基于servlet的实现,属于阻塞式编程,而springcloudgateway则是基于spring5中提供的webflux,属于响应式编程的实现,具备更好的性能.gateway快速入门1创建新的module,引入SpringCloudGetaway的依赖和nacos的服务发现依赖 <!–网关依赖–><dependency> <

    2022年10月9日
  • 外企入职第一封英文邮件_投外企要英文简历吗

    外企入职第一封英文邮件_投外企要英文简历吗   一份出色的Resume,是向外企求职的关键之一。不了解有关的常识和程式,不花费相当的心思来展示,以有纯正娴熟的英文功底,决不能获得单位的青睐。在一大堆错误百出、英文表达能力低劣或平庸,毫无针对性和创造性的Resume中,你的那份若能让人眼睛一亮,成功的机会必将大大增加,以下试着结合一个具体的例子给出说明和评述。   BalanceSheet:  基本方法选取适当的工作后,必须看清

    2022年10月20日
  • 免费的HTML5连载来了《HTML5网页开发实例具体解释》连载(六)媒体查询

    免费的HTML5连载来了《HTML5网页开发实例具体解释》连载(六)媒体查询

    2021年12月5日
  • target host is null

    target host is null在接口调用的时候出现targethostisnull的异常原因是因为接口地址没有加http://

    2022年10月19日

发表回复

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

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