BSON_NEW_FROM_JSON(3)
π BSON_NEW_FROM_JSON(3) π
okay bestie, welcome to the libbson manual page for bson_new_from_json() β this one is literally the glow-up from JSON to BSON, and yes, the vibes are immaculate β¨
β¨ SYNOPSIS β¨
bson_t *
bson_new_from_json (const uint8_t *data, ssize_t len, bson_error_t *error);
πΈ PARAMETERS πΈ
dataβ A UTF-8 encoded string containing valid JSON. That's the main character right there πlenβ The length ofdatain bytes excluding a trailing\0or-1to determine the length withstrlen(). So either you count it yourself or you letstrlen()do its thing πerrorβ An optional location for abson_error_t. Optional, but lowkey your bestie when things go sideways π«Ά
π DESCRIPTION π
The bson_new_from_json() function allocates and initializes a new bson_t by parsing the JSON found in data. It's giving "turn this text into BSON real quick" energy, no cap.
Only a single JSON object may exist in data β or an error will be set and NULL returned. One object, okay? Not a whole group chat of JSONs. π
β οΈ Deprecated behavior alert, bestie: If there are multiple comma-separated JSONs indata, the keys from all JSONs are merged in the returned BSON. For example,{"a": 1},{"b": 2}is parsed as{"a": 1, "b": 2}. If the first character encountered after the last valid JSON object is{, all following characters are ignored and no error is set. Otherwise, an error will be set andNULLreturned. fr fr, that's the deprecated behavior, so don't act surprised π
Errors
Errors are propagated via the error parameter. That's the whole mood: if something's wrong, it gets passed straight to your error. π§
π₯ RETURNS π₯
A newly allocated bson_t if successful, otherwise NULL and error is set. Slay when it works, check the error when it doesn't β¨
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
mwah π that's the whole page from libbson 2.5.6, dated Oct 09, 2026 β go forth and parse responsibly, bestie! π¦π
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms