https://www.mongodb.com/json-and-bson

 

JSON And BSON

Learn how MongoDB uses the lightweight and flexible BSON, an extension JSON, to maximize efficiency for programming languages

www.mongodb.com

bson 은 mongodb 에서 나온 개념인데 "binary JSON" 이다.

{"hello": "world"} →
\x16\x00\x00\x00           // total document size
\x02                       // 0x02 = type String
hello\x00                  // field name
\x06\x00\x00\x00world\x00  // field value
\x00                       // 0x00 = type EOO ('end of object')
 
{"BSON": ["awesome", 5.05, 1986]} →
\x31\x00\x00\x00
 \x04BSON\x00
 \x26\x00\x00\x00
 \x02\x30\x00\x08\x00\x00\x00awesome\x00
 \x01\x31\x00\x33\x33\x33\x33\x33\x33\x14\x40
 \x10\x32\x00\xc2\x07\x00\x00
 \x00
 \x00

txt 기반의 json 을 변형해서 binary 형식으로 serialize 했다.

https://bsonspec.org/spec.html

 

BSON (Binary JSON): Specification

BSON is a binary format in which zero or more ordered key/value pairs are stored as a single entity. We call this entity a document. The following grammar specifies version 1.1 of the BSON standard. We've written the grammar using a pseudo-BNF syntax. Vali

bsonspec.org

network protocol 정의할 때 보던 형식과 유사하다. 

728x90

+ Recent posts