1BSON_AS_JSON_WITH_OPTS(3)           libbson          BSON_AS_JSON_WITH_OPTS(3)
2
3
4

SYNOPSIS

6          char *
7          bson_as_json_with_opts (const bson_t *bson, size_t *length, const bson_json_opts_t *opts);
8

PARAMETERS

10bson: A bson_t.
11
12length: An optional location for the length of the resulting string.
13
14opts: A bson_json_opts_t.
15

DESCRIPTION

17       The  bson_as_json_with_opts()  encodes  bson  as  a UTF-8 string in the
18       MongoDB Extended JSON format.
19
20       The caller is responsible  for  freeing  the  resulting  UTF-8  encoded
21       string by calling bson_free() with the result.
22
23       If non-NULL, length will be set to the length of the result in bytes.
24
25       The  opts  structure  is used to pass options for the encoding process.
26       Please refer to the documentation of bson_json_opts_t for more details.
27

RETURNS

29       If successful, a newly allocated UTF-8 encoded  string  and  length  is
30       set.
31
32       Upon failure, NULL is returned.
33

EXAMPLE

35          bson_json_opts_t *opts = bson_json_opts_new (BSON_JSON_MODE_CANONICAL, BSON_MAX_LEN_UNLIMITED);
36          char *str = bson_as_json_with_opts (doc, NULL, opts);
37          printf ("%s\n", str);
38          bson_free (str);
39          bson_json_opts_destroy (opts);
40

AUTHOR

42       MongoDB, Inc
43
45       2017-present, MongoDB, Inc
46
47
48
49
501.25.1                           Nov 08, 2023        BSON_AS_JSON_WITH_OPTS(3)
Impressum