Module bson::extjson::de [−][src]
Deserializing MongoDB Extended JSON v2
Usage
Extended JSON can be deserialized using Bson
’s
TryFrom<serde_json::Value>
implementation. This implementation accepts both canonical and
relaxed extJSON, and the two modes can even be mixed within a single representation.
e.g.
let json_doc = json!({ "x": 5i32, "y": { "$numberInt": "5" }, "z": { "subdoc": "hello" } }); let bson: Bson = json_doc.try_into().unwrap(); // Bson::Document(...) let json_date = json!({ "$date": { "$numberLong": "1590972160292" } }); let bson_date: Bson = json_date.try_into().unwrap(); // Bson::DateTime(...) let invalid_ext_json = json!({ "$numberLong": 5 }); Bson::try_from(invalid_ext_json).expect_err("5 should be a string");
Enums
Error | Error cases that can occur during deserialization from extended JSON. |
Type Definitions
Result |