为什么叫BSON? [英] Why is it called BSON?

查看:79
本文介绍了为什么叫BSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么BSON是JSON序列化的吗?

So BSON is JSON serialized right?

{ hello: world} \x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00

但是为什么叫Binary Json?二进制代表什么?

But why is it called Binary Json? What does binary stands for?

我总是倾向于将二进制与10101010101相关联。但是,上面的BSON序列化格式不是101010101010形式。

I always tend to associate binary with 10101010101. But the BSON serialization format above wasn't in 101010101010 form.

有人可以为我解释一下Binary在这里的含义,以便我理解为什么将其称为Binary JSON吗?

Could someone explain for me what the Binary here means so I understand why it's called Binary JSON?

推荐答案

它是二进制而不是文本。 JSON是人类可读的文本,而BSON是二进制数据(仅字节)。您可以 将其写为1001010等,但是更常见的是一次显示每个字节(因此\x16仅为十六进制16,即十进制字节22)。基本上,这里的二进制用于将其与文本数据进行比较,而不是说它实际上特别是以2为底。

It's binary as opposed to text. Whereas JSON is human-readable text, BSON is binary data (just bytes). You could write it out as 1001010 etc, but it's more common to show each byte at a time (so \x16 is just hex 16, i.e. the decimal byte 22). Basically "binary" here is used to compare it with textual data, not to say that it's actually base 2 in particular.

这意味着您只能在情况下使用BSON您可以在其中传输任意二进制数据。例如,如果您想将BSON嵌入XML文档中(无论出于何种原因!),则必须先对其进行base64编码,因为XML是基于文本的表示形式。

This means that you can only use BSON in situations where you can transport arbitrary binary data. For example, if you wanted to embed BSON in an XML document (for whatever reason!) you'd have to base64 encode it first, because XML is a text-based representation.

这篇关于为什么叫BSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆