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
Copy file name to clipboardExpand all lines: README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,10 +50,11 @@ Note that if you are using `bson` through the `mongodb` crate, you do not need t
50
50
|`chrono-0_4`| Enable support for v0.4 of the [`chrono`](https://docs.rs/chrono/0.4) crate in the public API. | n/a | no |
51
51
|`uuid-1`| Enable support for v1.x of the [`uuid`](https://docs.rs/uuid/1.0) crate in the public API. | n/a | no |
52
52
|`time-0_3`| Enable support for v0.3 of the [`time`](https://docs.rs/time/0.3) crate in the public API. | n/a | no |
53
-
|`serde_with-3`| Enable [`serde_with`](https://docs.rs/serde_with/3.x) 3.x integrations for `bson::DateTime` and `bson::Uuid`.| serde_with | no |
54
-
|`serde_path_to_error`| Enable support for error paths via integration with [`serde_path_to_error`](https://docs.rs/serde_path_to_err/latest). This is an unstable feature and any breaking changes to `serde_path_to_error` may affect usage of it via this feature. | serde_path_to_error | no |
53
+
|`serde_with-3`| Enable [`serde_with`](https://docs.rs/serde_with/3.x) 3.x integrations for `bson::DateTime` and `bson::Uuid`.|`serde_with`| no |
54
+
|`serde_path_to_error`| Enable support for error paths via integration with [`serde_path_to_error`](https://docs.rs/serde_path_to_err/latest). This is an unstable feature and any breaking changes to `serde_path_to_error` may affect usage of it via this feature. |`serde_path_to_error`| no |
55
55
|`compat-3-0-0`| Required for future compatibility if default features are disabled. | n/a | no |
56
56
|`large_dates`| Increase the supported year range for some `bson::DateTime` utilities from +/-9,999 (inclusive) to +/-999,999 (inclusive). Note that enabling this feature can impact performance and introduce parsing ambiguities. | n/a | no |
57
+
|`serde_json-1`| Enable support for v1.x of the [`serde_json`](https://docs.rs/serde_json/1.x) crate in the public API. |`serde_json`| no |
/// This will create the [relaxed Extended JSON v2](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/) representation of the provided [`Bson`](../enum.Bson.html).
454
-
implFrom<Bson>forValue{
455
-
fnfrom(bson:Bson) -> Self{
456
-
bson.into_relaxed_extjson()
457
-
}
458
-
}
459
-
460
451
implBson{
461
-
/// Converts the Bson value into its [relaxed extended JSON representation](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/).
462
-
pubfninto_relaxed_extjson(self) -> Value{
463
-
matchself{
464
-
Bson::Double(v)if v.is_nan() => {
465
-
let s = if v.is_sign_negative(){"-NaN"}else{"NaN"};
//! Deserialization and serialization of [MongoDB Extended JSON v2](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/)
2
-
//!
3
-
//! ## Overview of Extended JSON
4
-
//!
5
-
//! MongoDB Extended JSON (abbreviated extJSON) is format of JSON that allows for the encoding of
6
-
//! BSON type information. Normal JSON cannot unambiguously represent all BSON types losslessly, so
7
-
//! an extension was designed to include conventions for representing those types.
8
-
//!
9
-
//! For example, a BSON binary is represented by the following format:
10
-
//! ```text
11
-
//! {
12
-
//! "$binary": {
13
-
//! "base64": <base64 encoded payload as a string>,
14
-
//! "subType": <subtype as a one or two character hex string>,
15
-
//! }
16
-
//! }
17
-
//! ```
18
-
//! For more information on extJSON and the complete list of translations, see the [official MongoDB documentation](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/).
19
-
//!
20
-
//! All MongoDB drivers and BSON libraries interpret and produce extJSON, so it can serve as a
21
-
//! useful tool for communicating between applications where raw BSON bytes cannot be used (e.g. via
22
-
//! JSON REST APIs). It's also useful for representing BSON data as a string.
23
-
//!
24
-
//! ### Canonical and Relaxed Modes
25
-
//!
26
-
//! There are two modes of extJSON: "Canonical" and "Relaxed". They are the same except for the
27
-
//! following differences:
28
-
//! - In relaxed mode, all BSON numbers are represented by the JSON number type, rather than the
29
-
//! object notation.
30
-
//! - In relaxed mode, the string in the datetime object notation is RFC 3339 (ISO-8601) formatted
31
-
//! (if the date is after 1970).
32
-
//!
33
-
//! e.g.
34
-
//! ```rust
35
-
//! # use bson::bson;
36
-
//! let doc = bson!({ "x": 5, "d": bson::DateTime::now() });
0 commit comments