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:
-
ClassDescriptionAnnotation that can be applied to classes, fields, and methods to tweak how they are handled by
BsonSerializerandBsonParser.Utility classes and methods for the@Bsonannotation.Builder class.Dynamically applies a@Bsonannotation to specified classes, methods, or fields.A collection of@BsonApply annotations.Utility classes and methods for the@BsonApplyannotation.Applies targetedBsonApplyannotations to aContext.Builder.Builder class.Metadata on bean properties specific to the BSON serializers and parsers pulled from the@Bsonannotation on the bean property.Metadata on classes specific to the BSON serializers and parsers pulled from the@Bsonannotation on the class.Annotation for specifying config properties defined inBsonSerializerandBsonParser.Utility classes and methods for the@BsonConfigannotation.AppliesBsonConfigannotations to aBsonParser.Builder.AppliesBsonConfigannotations to aBsonSerializer.Builder.IEEE 754-2008 Decimal128 BID (Binary Integer Decimal) encoding for BSON.Specialized input stream for parsing BSON (Binary JSON) streams.Interface for providing access toBsonClassMetaandBsonBeanPropertyMetaobjects.Specialized output stream for serializing BSON (Binary JSON) streams.Parses BSON (Binary JSON) into POJO models.Default parser, string input encoded as BASE64.Builder class.Default parser, string input encoded as spaced-hex.Session object that lives for the duration of a single use ofBsonParser.Builder class.Serializes POJO models to BSON (Binary JSON).Default serializer, BASE64 string output.Builder class.Default serializer, spaced-hex string output.Session object that lives for the duration of a single use ofBsonSerializer.Builder class.BSON element type codes per the BSON Specification 1.1.