Company
Date Published
Author
MongoDB
Word count
735
Language
English
Hacker News points
None

Summary

Libbson is a new shared library written in C for developers wanting to work with the BSON serialization format, providing an API that feels natural to C programmers while also being suitable as a base for higher-level MongoDB drivers. The library offers various features such as document iteration, field overwriting, Object Id generation, JSON conversion, and data validation. To address memory fragmentation issues, bson_t contains inline space allowing documents to be built directly on the stack, and its buffers grow in powers of two. Libbson also supports building sub-documents into parent documents' buffer, parsing BSON documents from network buffers, generating BSON documents into network buffers, and generating Object Ids without synchronization. The library is available at https://github.com/mongodb/libbson.