BSON(Binary JSON)是MongoDB用来存储文档的二进制格式——它使用额外的数据类型(如日期、ObjectId、二进制和正确的数字类型)扩展JSON,并且高效存储和遍历。理解BSON类型可以帮助您正确地存储数据。
BSON — 具有更多类型的binary JSON
JSON has limited types (string, number, boolean, null, object, array).
BSON adds: ObjectId, Date, Binary, Decimal128, distinct Int/Long/Double, Timestamp, etc.
→ BSON is more efficient (binary, typed, traversable) and richer than plain JSON text.
常见BSON数据类型
{
: (),
: ,
: (),
: (),
: (),
: ,
: ,
: (),
: (, ),
: [, ],
: { : },
:
}
