I have Json<Value>
object (from serde_json::Value
) with no Rust struct (because objects have quite many properties and it may change) and I would like to convert it to mongodb::Document
or bson
to save it to mongo, is there any integration or should I write transformer myself
serde_json::Value
implements Serialize
so just use bson::to_bson
, or bson::to_document
let value: serde_json::Value = serde_json::json!({"foo": "bar"});
let bson_value = bson::to_bson(&value);