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

NAME

6       bson_as_json_with_opts - bson_as_json_with_opts()
7

SYNOPSIS

9          char *
10          bson_as_json_with_opts (const bson_t *bson, size_t *length, const bson_json_opts_t *opts);
11

PARAMETERS

13bson: A bson_t.
14
15length: An optional location for the length of the resulting string.
16
17opts: A bson_json_opts_t.
18

DESCRIPTION

20       The  bson_as_json_with_opts()  encodes  bson  as  a UTF-8 string in the
21       MongoDB Extended JSON format.
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
28       The  opts  structure  is used to pass options for the encoding process.
29       Please refer to the documentation of bson_json_opts_t for more details.
30

RETURNS

32       If successful, a newly allocated UTF-8 encoded  string  and  length  is
33       set.
34
35       Upon failure, NULL is returned.
36

EXAMPLE

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

AUTHOR

45       MongoDB, Inc
46
48       2017-present, MongoDB, Inc
49
50
51
52
531.20.0                           Nov 18, 2021        BSON_AS_JSON_WITH_OPTS(3)
Impressum