1BSON_INIT_FROM_JSON(3) libbson BSON_INIT_FROM_JSON(3)
2
3
4
6 bool
7 bson_init_from_json (bson_t *bson,
8 const char *data,
9 ssize_t len,
10 bson_error_t *error);
11
13 • bson: Pointer to an uninitialized bson_t.
14
15 • data: A UTF-8 encoded string containing valid JSON.
16
17 • len: The length of data in bytes excluding a trailing \0 or -1 to de‐
18 termine the length with strlen().
19
20 • error: An optional location for a bson_error_t.
21
23 The bson_init_from_json() function will initialize a new bson_t by
24 parsing the JSON found in data. Only a single JSON object may exist in
25 data or an error will be set and false returned.
26
27 data should be in MongoDB Extended JSON format.
28
30 If there are multiple comma-separated JSONs in data, the keys from all
31 JSONs are merged in the returned BSON. For example, {"a": 1},{"b": 2}
32 is parsed as {"a": 1, "b": 2}.
33
34 If the first character encountered after the last valid JSON object is
35 {, all following characters are ignored and no error is set. Other‐
36 wise, an error will be set and NULL returned.
37
38 This deprecated behavior is subject to change in a future release.
39
41 Errors are propagated via the error parameter.
42
44 Returns true if valid JSON was parsed, otherwise false and error is
45 set. On success, bson is initialized and must be freed with
46 bson_destroy(), otherwise bson is invalid.
47
49 MongoDB, Inc
50
52 2017-present, MongoDB, Inc
53
54
55
56
571.25.1 Nov 08, 2023 BSON_INIT_FROM_JSON(3)