BSON_JSON_OPTS_T(3)

πŸ’… BSON_JSON_OPTS_T(3) β€” the libbson girlies' guide to BSON β†’ JSON encoding options ✨

okay so bestie, this is a libbson manpage, section 3, and it's literally all about "BSON to JSON encoding options" β€” like the little settings bag you hand over when you want your BSON turned into MongoDB Extended JSON. no cap, that's the whole vibe 🫢


✨ SYNOPSIS ✨

first things first, pull in the header:

#include <bson/bson.h>

then meet the star of the show, she's opaque and mysterious:

typedef struct _bson_json_opts_t bson_json_opts_t;

and these two functions are her whole entourage πŸ’…

bson_json_opts_t *
bson_json_opts_new (bson_json_mode_t mode, int32_t max_len);

void
bson_json_opts_destroy (bson_json_opts_t *opts);

πŸŽ€ DESCRIPTION πŸŽ€

The bson_json_opts_t structure contains options for encoding BSON into MongoDB Extended JSON. that's it, that's her job, and she ate πŸ”₯

  • mode β€” this member is a bson_json_mode_t and it defines the encoding mode. iykyk, pick your mode, pick your destiny ⭐
  • max_len β€” this member holds a maximum length for the resulting JSON string. Encoding will stop once the serialised string has reached this length. literally she will cut herself off mid-sentence at that length, so know what you're asking for 😭

and if you want the whole thing? the full BSON document, no limits, main character energy? use BSON_MAX_LEN_UNLIMITED. periodt πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

  • bson_as_json_with_opts() β€” go read it, she's the one who actually puts these options to work πŸ’–

🌸 AUTHOR 🌸

MongoDB, Inc β€” icons only πŸ‘‘

2009-present, MongoDB, Inc. β€” respect the copyright bestie, it's giving longevity πŸŽ€


and that's the whole page, no notes πŸ’œ go forth and encode responsibly ✨

version 2.5.6, dated Oct 09, 2026 β€” that's the libbson energy, signing off, mwah πŸ«ΆπŸ’…

πŸ“¦ where this page comes from