8 releases (4 stable)

Uses old Rust 2015

1.1.1 Jul 10, 2021
1.1.0 Jan 2, 2019
1.0.1 Dec 31, 2018
1.0.0 Apr 20, 2017
0.1.0 Jul 31, 2016

#83 in Encoding

Download history 28572/week @ 2023-12-16 6080/week @ 2023-12-23 13744/week @ 2023-12-30 18625/week @ 2024-01-06 19008/week @ 2024-01-13 28082/week @ 2024-01-20 29147/week @ 2024-01-27 30317/week @ 2024-02-03 33517/week @ 2024-02-10 27112/week @ 2024-02-17 32852/week @ 2024-02-24 31580/week @ 2024-03-02 28676/week @ 2024-03-09 25206/week @ 2024-03-16 28158/week @ 2024-03-23 26815/week @ 2024-03-30

115,129 downloads per month
Used in 150 crates (42 directly)

MIT/Apache

14KB
386 lines

serde-transcode

Build Status

Documentation

Transcode from one Serde format to another.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Transcode from one Serde format to another.

This crate provides functionality to "transcode" from an arbitrary Serde Deserializer to an arbitrary Serde Serializer without needing to collect the entire input into an intermediate form in memory. For example, you could translate a stream of JSON data into a stream of CBOR data, or translate JSON into its pretty-printed form.

Examples

Translate a JSON file to a pretty-printed version.

extern crate serde;
extern crate serde_json;
extern crate serde_transcode;

use serde::Serialize;
use serde_json::{Serializer, Deserializer};
use std::io::{Read, Write, BufReader, BufWriter};
use std::fs::File;

fn main() {
    let reader = BufReader::new(File::open("input.json").unwrap());
    let writer = BufWriter::new(File::create("output.json").unwrap());

    let mut deserializer = Deserializer::from_reader(reader);
    let mut serializer = Serializer::pretty(writer);
    serde_transcode::transcode(&mut deserializer, &mut serializer).unwrap();
    serializer.into_inner().flush().unwrap();
}

Dependencies

~110–345KB