serialize method

BsonBinary serialize(
  1. dynamic object, [
  2. int offset = 0
])

Implementation

BsonBinary serialize(var object, [int offset = 0]) {
  if (!((object is Map) || (object is List))) {
    throw Exception('Invalid value for BSON serialize: $object');
  }
  var bsonObject = BsonObject.bsonObjectFrom(object);
  var buffer = BsonBinary(bsonObject.byteLength() + offset);
  buffer.offset = offset;
  BsonObject.bsonObjectFrom(object).packValue(buffer);
  return buffer;
}