BSON_AS_JSON(3)
π BSON_AS_JSON π
okay bestie, welcome to BSON_AS_JSON(3) from the libbson manual β¨ this one's a little bittersweet because she's deprecated, but she still works and we're gonna learn her fr fr π«Ά
β οΈ WARNING β οΈ
Deprecated since version 1.29.0: use bson_as_canonical_extended_json() and bson_as_relaxed_extended_json() instead β those ones use the same MongoDB Extended JSON format as literally every other MongoDB driver, so you're speaking the same language as the whole squad π
And if you're dead set on continuing to produce Legacy Extended JSON, then use bson_as_legacy_extended_json(). that's the move π
not me warning you before I even say what the function does π that's how serious this is, bestie.
β¨ SYNOPSIS β¨
char *
bson_as_json (const bson_t *bson, size_t *length);
π PARAMETERS π
bsonβ abson_t. yeah. that's the whole description. she's lowkey mysterious πlengthβ an optional location for the length of the resulting string.
π¦ DESCRIPTION π¦
bson_as_json() encodes bson as a UTF-8 string using libbson's Legacy Extended JSON. that's the whole vibe πΈ
and listen β the caller is responsible for freeing the resulting UTF-8 encoded string by calling bson_free() with the result. yes YOU. it's your string now, you have to take care of it π don't just leave it there, that's not main character energy, that's a memory leak π
if length is non-NULL, length will be set to the length of the result in bytes. so if you pass a pointer, she fills you in on the tea π
π RETURNS π
if it works out? you get a newly allocated UTF-8 encoded string, and length gets set. slay π
upon failure, NULL is returned. and that's it. no string, no length, just NULL and vibes π
always check for NULL, bestie. always. iykyk π
π AUTHOR π
MongoDB, Inc β iconic, honestly π
π COPYRIGHT π
2009-present, MongoDB, Inc.
and that's the page!! this was BSON_AS_JSON(3) from libbson version 1.30.13, dated Oct 09, 2026 π«Ά go forth and use the extended JSON functions instead, bestie, you got this πβ¨π
π¦ where this page comes from
- fedora 43: libbson-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- fedora 43: libbson-devel 1.30.13-1.fc43 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms