BSON_JSON_READER_NEW(3)

πŸ’… BSON_JSON_READER_NEW(3) β€” like, the libbson one, section 3, bestie ✨

okay so picture this: you're deep in libbson land and you need a reader that just... streams. that's literally this whole function. it's giving "main character energy" for JSON reading, periodt.


✨ SYNOPSIS ✨

bson_json_reader_t *
bson_json_reader_new (void *data,
                      bson_json_destroy_cb dcb,
                      bool allow_multiple,
                      size_t buf_size);

wait no 😭 β€” do NOT let me mess up the order, that's the one thing we do not do. the actual signature is exactly this, copy it character for character babes:

bson_json_reader_t *
bson_json_reader_new (void *data,
                      bson_json_reader_cb cb,
                      bson_json_destroy_cb dcb,
                      bool allow_multiple,
                      size_t buf_size);

five params, in that exact order. cb goes second, dcb third. slay 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • data β€” a user-defined pointer. that's your little payload, bestie, it's whatever you want to hand over. you do you πŸ’–
  • cb β€” a bson_json_reader_cb. your callback, the one doing the actual reading work.
  • dcb β€” a bson_json_destroy_cb. the cleanup callback, so nothing leaks. iconic behaviour honestly.
  • allow_multiple β€” unused. like, genuinely unused. it's just sitting there. not me pointing at it πŸ’€
  • buf_size β€” a size_t containing the requested internal buffer size. you pick how big the internal buffer is, we simply respect it ✨

🌸 DESCRIPTION 🌸

creates a new bson_json_reader_t that can read from an arbitrary data source in a streaming fashion. yes, streaming. we are not loading the whole thing into memory like some kind of clown 🀑 β€” it flows, it vibes, it reads as it goes. highkey elegant.

and because you're gonna ask: the allow_multiple parameter is unused. i said what i said. it's in the signature, it's in the docs, and it does nothing. no cap. 🧚

⚠️ heads up: allow_multiple is unused. i'm repeating it a third time because the manpage repeats it a third time, and honestly? it deserves the airtime at this point πŸ’€

πŸ’œ RETURNS πŸ’œ

a newly allocated bson_json_reader_t β€” fresh out the oven, yours to keep πŸ‘‘

and you must free it with bson_json_reader_destroy(). that's not a suggestion, that's a whole thing. free your reader or the memory leaks and it's not cute 🚨😭


🌈 AUTHOR 🌈

MongoDB, Inc πŸ‘‘ (yes, that MongoDB)


2009-present, MongoDB, Inc. β€” everything from 2009 up through today, all theirs 🫢


okay that's the whole page, bestie! remember: data, cb, dcb, allow_multiple (unused!!), buf_size, in exactly that order, and always, always bson_json_reader_destroy() it afterwards. πŸ’…βœ¨

this little love letter came to you from libbson, version 2.5.6, dated Oct 09, 2026 β€” iykyk πŸ¦‹πŸŒΈ bye bestie!! πŸ“

πŸ“¦ where this page comes from