Package org.apache.juneau.marshall.bson


package org.apache.juneau.marshall.bson
BSON (Binary JSON) marshalling support.

BSON is a binary serialization format used by MongoDB. It extends JSON with additional types (datetime, binary, 32-bit/64-bit integers, decimal128) and uses little-endian byte order.

Juneau provides BsonSerializer and BsonParser for serialization and parsing, plus Bson for a combined API.

Type mapping (summary)
  • Beans/maps → BSON document (0x03)
  • Collections/arrays → BSON array (0x04)
  • Strings/enums → BSON string (0x02)
  • Numbers → int32 (0x10), int64 (0x12), double (0x01), or decimal128 (0x13)
  • Dates → BSON datetime (0x09) or ISO 8601 string
  • byte[] → BSON binary (0x05)

Compared to MsgPack: BSON is length-prefixed and little-endian; supports typed integers (int32/int64), native datetime, and decimal128. Compared to JSON: BSON is binary and more compact for typed data.

See Also: