Crates.io | mongo_archive |
lib.rs | mongo_archive |
version | 0.1.0 |
source | src |
created_at | 2024-05-31 07:34:14.302752 |
updated_at | 2024-05-31 07:34:14.302752 |
description | A parser for MongoDB archive. |
homepage | |
repository | https://github.com/zerodegress/mongo_archive |
max_upload_size | |
id | 1257750 |
size | 11,472 |
A parser for MongoDB archive.
use std::{
fs::OpenOptions,
io::{BufWriter, Cursor},
};
use mongo_archive::MongoArchive;
fn main() -> anyhow::Result<()> {
// read and parse as bson::Bson
let docs = MongoArchive::from_reader(Cursor::new(include_bytes!("./createshiprecords"))).parse();
let json_value: serde_json::Value = bson::from_bson(docs)?;
let out = OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.read(false)
.open("createshiprecords.json")?;
let buf_writer = BufWriter::new(out);
serde_json::to_writer(buf_writer, &json_value)?;
Ok(())
}