192 releases (stable)

Uses old Rust 2015

1.0.152 Dec 26, 2022
1.0.148 Nov 28, 2022
1.0.140 Jul 20, 2022
1.0.136 Jan 25, 2022
0.8.19 Nov 23, 2016

#398 in Procedural macros

Download history 1284548/week @ 2022-10-07 1285346/week @ 2022-10-14 1401733/week @ 2022-10-21 1294412/week @ 2022-10-28 1390921/week @ 2022-11-04 1341213/week @ 2022-11-11 1230053/week @ 2022-11-18 1365198/week @ 2022-11-25 1404547/week @ 2022-12-02 1380913/week @ 2022-12-09 1282951/week @ 2022-12-16 842572/week @ 2022-12-23 1050894/week @ 2022-12-30 1389083/week @ 2023-01-06 1313460/week @ 2023-01-13 1381356/week @ 2023-01-20

5,296,477 downloads per month
Used in 33,730 crates (5,570 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

~195–590KB
~14K SLoC