#serde #serialization #no-std

no-std serde_derive

Macros 1.1 implementation of #[derive(Serialize, Deserialize)]

170 releases (stable)

Uses old Rust 2015

1.0.130 Aug 28, 2021
1.0.127 Jul 31, 2021
1.0.125 Mar 22, 2021
1.0.118 Dec 5, 2020
0.8.19 Nov 23, 2016

#208 in Encoding

Download history 502279/week @ 2021-05-29 520002/week @ 2021-06-05 525477/week @ 2021-06-12 507683/week @ 2021-06-19 502647/week @ 2021-06-26 497197/week @ 2021-07-03 511035/week @ 2021-07-10 515233/week @ 2021-07-17 525667/week @ 2021-07-24 613238/week @ 2021-07-31 616666/week @ 2021-08-07 627793/week @ 2021-08-14 693282/week @ 2021-08-21 687311/week @ 2021-08-28 623227/week @ 2021-09-04 736740/week @ 2021-09-11

2,371,614 downloads per month
Used in 20,030 crates (4,815 directly)

MIT/Apache

300KB
7K SLoC

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.


You may be looking for:

Serde in action

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let point = Point { x: 1, y: 2 };

    // Convert the Point to a JSON string.
    let serialized = serde_json::to_string(&point).unwrap();

    // Prints serialized = {"x":1,"y":2}
    println!("serialized = {}", serialized);

    // Convert the JSON string back to a Point.
    let deserialized: Point = serde_json::from_str(&serialized).unwrap();

    // Prints deserialized = Point { x: 1, y: 2 }
    println!("deserialized = {:?}", deserialized);
}

Getting help

Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the #general or #beginners channels of the unofficial community Discord, the #rust-usage channel of the official Rust Project Discord, or the #general stream in Zulip. For asynchronous, consider the [rust] tag on StackOverflow, the /r/rust subreddit which has a pinned weekly easy questions post, or the Rust Discourse forum. It's acceptable to file a support issue in this repo but they tend not to get as many eyes as any of the above and may get closed without a response after some time.

Dependencies

~310–730KB
~18K SLoC