二进制json(BSON)中的二进制是什么?

问题描述 投票:1回答:1

为什么二进制字用于BSON,当它以如下格式存储数据时

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

对于这种格式,我们还需要解释器来解析并将其转换为机器指令和

它以什么方式压缩实际的JSON数据并快速解释?

mongodb mongoose nosql mongodb-query bson
1个回答
0
投票

它是二进制数据类型的类比语义。 BSON二进制文件具有一个字节数组,表示从0到127的内部子类型。

例如:字节0000 0000 1000表示六进制“\ x08”,表示BSON规范中的boolean类型。

驱动程序将负责编码和解码格式UTF-8到BSON和存储引擎(如MongoDB中的WiredTiger)将负责对BSON格式的数据进行序列化和反序列化。

© www.soinside.com 2019 - 2024. All rights reserved.