MongoDB's Java driver offers five document classes for working with BSON data. Document is recommended for most use cases as it provides flexibility and ease of use through a Map interface. BsonDocument offers type-safe BSON handling, RawBsonDocument provides immutable, lazy-parsed byte arrays for performance-critical scenarios, JsonObject works directly with JSON strings, and BasicDBObject exists only for legacy compatibility. The article explains implementation details, conversion methods, and compares MongoDB's approach with Oracle's OSON and PostgreSQL's JSONB handling.

Sort: