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

Bson library for Dart programming language. BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. It 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
130
pub points
90%
popularity

Publisher

unverified uploader

Bson library for Dart programming language. BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents. It 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