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

Bson library for Dart programming language. BSON, short for Binary JSON, is a binary-encoded serialization of JSON-like documents.

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
0
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.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

www.paypal.com

License

unknown (license)

Dependencies

decimal, fixnum, packages_extensions, power_extensions, rational, uuid

More

Packages that depend on bson