bson 5.0.5 copy "bson: ^5.0.5" to clipboard
bson: ^5.0.5 copied to clipboard

Bson library for Dart. BSON is a binary-encoded serialization of JSON-like documents. The package allows also eJson and object serialization/deserialization.

example/example.dart

import 'package:bson/bson.dart';
import 'package:fixnum/fixnum.dart';

void main() {
  var objectId = ObjectId.parse('51c87a81a58a563d1304f4ed');
  var document = <String, dynamic>{
    '_id': objectId,
    'int32': 78954,
    'int64': Int64(-1),
    'date': DateTime(2020),
    'map': {
      'a': 99,
      'subList': [Int64(1), Int64(2), Int64(3)]
    },
    'list': [
      1,
      2,
      3,
      {'b': 29}
    ]
  };

  var bsonBinary = BsonCodec.serialize(document);

  var result = BsonCodec.deserialize(bsonBinary);

  var checkValue = result['list'][3]['b'] == document['list'][3]['b'];
  print('The result is ${checkValue ? 'correct' : 'uncorrect'}');
}
16
likes
150
points
15.1k
downloads

Publisher

unverified uploader

Weekly Downloads

Bson library for Dart. BSON is a binary-encoded serialization of JSON-like documents. The package allows also eJson and object serialization/deserialization.

Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

www.paypal.com

License

MIT (license)

Dependencies

decimal, fixnum, packages_extensions, power_extensions, rational, uuid

More

Packages that depend on bson