1BSON_ARRAY_AS_RELAXED_EXTENDED_JSON(3l)ibbsBoSnON_ARRAY_AS_RELAXED_EXTENDED_JSON(3)
2
3
4
6 bson_array_as_relaxed_extended_json - bson_array_as_relaxed_ex‐
7 tended_json()
8
10 char *
11 bson_array_as_relaxed_extended_json (const bson_t *bson, size_t *length);
12
14 • bson: A bson_t.
15
16 • length: An optional location for the length of the resulting string.
17
19 The bson_as_relaxed_extended_json() encodes bson as a UTF-8 string in
20 the relaxed MongoDB Extended JSON format, except the outermost element
21 is encoded as a JSON array, rather than a JSON document.
22
23 The caller is responsible for freeing the resulting UTF-8 encoded
24 string by calling bson_free() with the result.
25
26 If non-NULL, length will be set to the length of the result in bytes.
27
29 If successful, a newly allocated UTF-8 encoded string and length is
30 set.
31
32 Upon failure, NULL is returned.
33
35 #include <bson/bson.h>
36
37 int main ()
38 {
39 bson_t bson;
40 char *str;
41
42 bson_init (&bson);
43 /* BSON array is a normal BSON document with integer values for the keys,
44 * starting with 0 and continuing sequentially
45 */
46 BSON_APPEND_DOUBLE (&bson, "0", 3.14);
47 BSON_APPEND_UTF8 (&bson, "1", "bar");
48
49 str = bson_array_as_relaxed_extended_json (&bson, NULL);
50 /* Prints
51 * [ 3.14, "bar" ]
52 */
53 printf ("%s\n", str);
54 bson_free (str);
55
56 bson_destroy (&bson);
57 }
58
60 MongoDB, Inc
61
63 2017-present, MongoDB, Inc
64
65
66
67
681.24.3 Aug 17,B2S0O2N3_ARRAY_AS_RELAXED_EXTENDED_JSON(3)