1.BSON types
BSON has more types than JSON: alongside string, boolean, null, object and array, it has distinct number types (double, int32, int64, decimal128), a real date type, ObjectId, binary data, regex, and a couple of rarely used legacy types.
Key features
- string, boolean, null, object and array exist in both JSON and BSON
- double, int32, int64 and decimal128 are four distinct BSON number types
- date, timestamp, objectId, binary and regex have no JSON equivalent
- timestamp is an internal type for replication, not for application dates — use date
- JavaScript/code types exist for legacy server-side scripting, rarely used today
The BSON type list
- JSON
- One generic "number"
- No fixed width
- No exact decimal type
- BSON
- double, int32, int64, decimal128
- Each has a fixed, known width
- decimal128 is exact for money
Command
{
"text": "value", // string
"count": NumberInt(1), // int32
"big": NumberLong(1), // int64
"price": NumberDecimal("1.00"), // decimal128
"when": ISODate("2026-01-01") // date
}BSON has more types than JSON: double/int32/int64/decimal128 instead of one number, plus date, objectId, binary, regex. Use decimal128 for money.