- What is BSON?
- Binary JSON — MongoDB's storage format. Adds types that JSON lacks (ObjectId, Date, Binary, Decimal128) and encodes them in a compact binary layout. Every MongoDB document is stored as BSON.
- When do I see BSON hex?
- MongoDB wire protocol dumps, sharding replication logs, and driver debugging output. Rare in day-to-day work; essential when diagnosing low-level DB issues.
- Does it preserve BSON-specific types in JSON?
- Approximations: ObjectId as 24-char string, Date as ISO 8601 string, Binary as base64. The conversion is lossy for types that have no JSON equivalent — round-tripping back may differ.
- Can I convert JSON to BSON?
- Yes, bidirectional. Input JSON is parsed and serialized as BSON hex. Types with MongoDB semantics (ObjectId-style strings) are upgraded automatically.