You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* deprecate `bson_as_json` and `bson_array_as_json`
* add `bson_as_legacy_extended_json` and `bson_array_as_legacy_extended_json` as non-deprecated alternatives
* remove use of deprecated calls
* document libbson's Legacy Extended JSON
Copy file name to clipboardExpand all lines: src/libbson/NEWS
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Deprecated:
7
7
* Compiling with `BSON_MEMCHECK` defined is deprecated.
8
8
* `bson_in_range_*` and `bson_cmp_*` functions.
9
9
* `bson_atomic_*` and `bson_thrd_yield` functions.
10
+
* `bson_as_json` and `bson_array_as_json` are deprecated due to producing non-portable Legacy Extended JSON. Prefer Canonical Extended JSON or Relaxed Extended JSON for portability. To continue using Legacy Extended JSON, use `bson_as_legacy_extended_json` and `bson_array_as_legacy_extended_json`.
Copy file name to clipboardExpand all lines: src/libbson/doc/bson_array_as_canonical_extended_json.rst
+8-26Lines changed: 8 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,9 @@ Parameters
20
20
Description
21
21
-----------
22
22
23
-
The :symbol:`bson_array_as_canonical_extended_json()` encodes ``bson`` as a UTF-8 string in the canonical `MongoDB Extended JSON format`_, except the outermost element is encoded as a JSON array, rather than a JSON document.
23
+
:symbol:`bson_array_as_canonical_extended_json()` encodes ``bson`` as a UTF-8 string in Canonical Extended JSON.
24
+
The outermost element is encoded as a JSON array (``[ ... ]``), rather than a JSON document (``{ ... }``).
25
+
See `MongoDB Extended JSON format`_ for a description of Extended JSON formats.
24
26
25
27
The caller is responsible for freeing the resulting UTF-8 encoded string by calling :symbol:`bson_free()` with the result.
26
28
@@ -36,31 +38,11 @@ Upon failure, NULL is returned.
36
38
Example
37
39
-------
38
40
39
-
.. code-block:: c
40
-
41
-
#include <bson/bson.h>
42
-
43
-
int main ()
44
-
{
45
-
bson_t bson;
46
-
char *str;
47
-
48
-
bson_init (&bson);
49
-
/* BSON array is a normal BSON document with integer values for the keys,
The :symbol:`bson_array_as_json()` function shall encode ``bson`` as a UTF-8
24
-
string using libbson's legacy JSON format, except the outermost element is
25
-
encoded as a JSON array, rather than a JSON document. This function is
26
-
superseded by :symbol:`bson_array_as_canonical_extended_json()` and
27
-
:symbol:`bson_array_as_relaxed_extended_json()`, which use the same
28
-
`MongoDB Extended JSON format`_ as all other MongoDB drivers.
29
-
The caller is responsible for freeing the resulting UTF-8 encoded string by
30
-
calling :symbol:`bson_free()` with the result.
28
+
:symbol:`bson_array_as_json()` encodes ``bson`` as a UTF-8 string using :doc:`libbson's Legacy Extended JSON <legacy_extended_json>`.
29
+
The outermost element is encoded as a JSON array (``[ ... ]``), rather than a JSON document (``{ ... }``).
30
+
This function is superseded by :symbol:`bson_array_as_canonical_extended_json()` and :symbol:`bson_array_as_relaxed_extended_json()`, which use the same `MongoDB Extended JSON format`_ as all other MongoDB drivers.
31
+
To continue producing Legacy Extended JSON, :symbol:`bson_array_as_legacy_extended_json()` may be used.
32
+
33
+
The caller is responsible for freeing the resulting UTF-8 encoded string by calling :symbol:`bson_free()` with the result.
31
34
32
35
If non-NULL, ``length`` will be set to the length of the result in bytes.
33
36
@@ -38,36 +41,6 @@ If successful, a newly allocated UTF-8 encoded string and ``length`` is set.
38
41
39
42
Upon failure, NULL is returned.
40
43
41
-
Example
42
-
-------
43
-
44
-
.. code-block:: c
45
-
46
-
#include <bson/bson.h>
47
-
48
-
int main ()
49
-
{
50
-
bson_t bson;
51
-
char *str;
52
-
53
-
bson_init (&bson);
54
-
/* BSON array is a normal BSON document with integer values for the keys,
* ``length``: An optional location for the length of the resulting string.
19
+
20
+
Description
21
+
-----------
22
+
23
+
:symbol:`bson_array_as_legacy_extended_json()` encodes ``bson`` as a UTF-8 string using :doc:`libbson's Legacy Extended JSON <legacy_extended_json>`.
24
+
The outermost element is encoded as a JSON array (``[ ... ]``), rather than a JSON document (``{ ... }``).
25
+
This function is superseded by :symbol:`bson_array_as_canonical_extended_json()` and :symbol:`bson_array_as_relaxed_extended_json()`, which use the same `MongoDB Extended JSON format`_ as all other MongoDB drivers.
26
+
27
+
The caller is responsible for freeing the resulting UTF-8 encoded string by calling :symbol:`bson_free()` with the result.
28
+
29
+
If non-NULL, ``length`` will be set to the length of the result in bytes.
30
+
31
+
Returns
32
+
-------
33
+
34
+
If successful, a newly allocated UTF-8 encoded string and ``length`` is set.
35
+
36
+
Upon failure, NULL is returned.
37
+
38
+
Example
39
+
-------
40
+
41
+
.. literalinclude:: ../examples/extended-json.c
42
+
:language: c
43
+
:start-after: // bson_array_as_legacy_extended_json ... begin
44
+
:end-before: // bson_array_as_legacy_extended_json ... end
Copy file name to clipboardExpand all lines: src/libbson/doc/bson_array_as_relaxed_extended_json.rst
+8-26Lines changed: 8 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,9 @@ Parameters
20
20
Description
21
21
-----------
22
22
23
-
The :symbol:`bson_as_relaxed_extended_json()` encodes ``bson`` as a UTF-8 string in the relaxed `MongoDB Extended JSON format`_, except the outermost element is encoded as a JSON array, rather than a JSON document.
23
+
:symbol:`bson_as_relaxed_extended_json()` encodes ``bson`` as a UTF-8 string in the Relaxed Extended JSON.
24
+
The outermost element is encoded as a JSON array (``[ ... ]``), rather than a JSON document (``{ ... }``).
25
+
See `MongoDB Extended JSON format`_ for a description of Extended JSON formats.
24
26
25
27
The caller is responsible for freeing the resulting UTF-8 encoded string by calling :symbol:`bson_free()` with the result.
26
28
@@ -36,31 +38,11 @@ Upon failure, NULL is returned.
36
38
Example
37
39
-------
38
40
39
-
.. code-block:: c
40
-
41
-
#include <bson/bson.h>
42
-
43
-
int main ()
44
-
{
45
-
bson_t bson;
46
-
char *str;
47
-
48
-
bson_init (&bson);
49
-
/* BSON array is a normal BSON document with integer values for the keys,
The :symbol:`bson_as_json()` function shall encode ``bson`` as a UTF-8 string using libbson's legacy JSON format. This function is superseded by :symbol:`bson_as_canonical_extended_json()` and :symbol:`bson_as_relaxed_extended_json()`, which use the same `MongoDB Extended JSON format`_ as all other MongoDB drivers.
28
+
:symbol:`bson_as_json()` encodes ``bson`` as a UTF-8 string using :doc:`libbson's Legacy Extended JSON <legacy_extended_json>`.
29
+
This function is superseded by :symbol:`bson_as_canonical_extended_json()` and :symbol:`bson_as_relaxed_extended_json()`, which use the same `MongoDB Extended JSON format`_ as all other MongoDB drivers.
30
+
To continue producing Legacy Extended JSON, :symbol:`bson_as_legacy_extended_json()` may be used.
24
31
25
32
The caller is responsible for freeing the resulting UTF-8 encoded string by calling :symbol:`bson_free()` with the result.
26
33
@@ -33,32 +40,6 @@ If successful, a newly allocated UTF-8 encoded string and ``length`` is set.
0 commit comments