#serde #serialization #no-std

macro no-std serde_derive

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

178 releases (stable)

Uses old Rust 2015

new 1.0.138 Jul 2, 2022
1.0.136 Jan 25, 2022
1.0.132 Dec 16, 2021
1.0.130 Aug 28, 2021
0.8.19 Nov 23, 2016

#125 in Procedural macros

Download history 843026/week @ 2022-03-15 831509/week @ 2022-03-22 879846/week @ 2022-03-29 861458/week @ 2022-04-05 806657/week @ 2022-04-12 874432/week @ 2022-04-19 898169/week @ 2022-04-26 969068/week @ 2022-05-03 940857/week @ 2022-05-10 928801/week @ 2022-05-17 852508/week @ 2022-05-24 884185/week @ 2022-05-31 957023/week @ 2022-06-07 940286/week @ 2022-06-14 915936/week @ 2022-06-21 835235/week @ 2022-06-28

3,813,981 downloads per month
Used in 27,425 crates (5,243 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 #rust-questions or #rust-beginners channels of the unofficial community Discord (invite: https://discord.gg/rust-lang-community, the #rust-usage or #beginners channels of the official Rust Project Discord (invite: https://discord.gg/rust-lang), 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

~235–650KB
~16K SLoC