There is a conversion function:

fn get_data_string(result: MongoResult<Document>) -> Result<Json, String> { match result { Ok(doc) => Ok(Bson::Document(doc).to_json()), Err(e) => Err(format!("{}", e)) } } 

Compilation crashes:

 Ok(doc) => Ok(Bson::Document(doc).to_json()), expected enum `rustc_serialize::json::Json`, found enum `serde_json::value::Value` 

What exactly is the error, because there is a cast to JSON

UPD: The error is that Bson :: Document contains its own method to_json, but how do I call to_json, which I connected to

 use rustc_serialize::json::{Json, ToJson}; 
  • UFCS should help. - ozkriff

0