getml / reflect-cpp

A C++20 library for fast serialization, deserialization and validation using reflection. Supports JSON, BSON, CBOR, flexbuffers, msgpack, TOML, XML, YAML / msgpack.org[C++20]
https://getml.github.io/reflect-cpp/
MIT License
901 stars 76 forks source link

BSON support using libbson #22

Closed liuzicheng1987 closed 6 months ago

liuzicheng1987 commented 8 months ago

BSON is a binary format similar to JSON (as the name implies). The standard implementation is written in C: https://mongoc.org/libbson/current/index.html

BSON is used by many NoSQL databases, including MongoDB. It would be nice to be able to interface NoSQL-Databases in a type-safe way and this is why it could be very rewarding to add BSON support in reflect-cpp.

Generally speaking, any serialization format can be integrated by implementing the IsReader and IsWriter concepts, which are documented here: https://github.com/getml/reflect-cpp/blob/main/docs/supporting_your_own_format.md. The way I see it, it should be fairly straightforward to implement these concepts for libbson.

You should implement tests for this, in the same way the tests are set up for flexbuffers - by providing a Dockerfile that contains a reproducible environment in which the tests can be compiled and run:

https://github.com/getml/reflect-cpp/tree/main/tests/flexbuffers