1 <!-- Serde readme rendered on crates.io -->
3 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
7 You may be looking for:
9 - [An overview of Serde](https://serde.rs/)
10 - [Data formats supported by Serde](https://serde.rs/#data-formats)
11 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/derive.html)
12 - [Examples](https://serde.rs/examples.html)
13 - [API documentation](https://docs.serde.rs/serde/)
14 - [Release notes](https://github.com/serde-rs/serde/releases)
19 use serde::{Serialize, Deserialize};
21 #[derive(Serialize, Deserialize, Debug)]
28 let point = Point { x: 1, y: 2 };
30 // Convert the Point to a JSON string.
31 let serialized = serde_json::to_string(&point).unwrap();
33 // Prints serialized = {"x":1,"y":2}
34 println!("serialized = {}", serialized);
36 // Convert the JSON string back to a Point.
37 let deserialized: Point = serde_json::from_str(&serialized).unwrap();
39 // Prints deserialized = Point { x: 1, y: 2 }
40 println!("deserialized = {:?}", deserialized);
46 Serde is one of the most widely used Rust libraries so any place that Rustaceans
47 congregate will be able to help you out. For chat, consider trying the
48 [#rust-questions] or [#rust-beginners] channels of the unofficial community
49 Discord (invite: <https://discord.gg/rust-lang-community>, the [#rust-usage] or
50 [#beginners] channels of the official Rust Project Discord (invite:
51 <https://discord.gg/rust-lang>), or the [#general][zulip] stream in Zulip. For
52 asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the
53 [/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust
54 [Discourse forum][discourse]. It's acceptable to file a support issue in this
55 repo but they tend not to get as many eyes as any of the above and may get
56 closed without a response after some time.
58 [#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513
59 [#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281
60 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
61 [#beginners]: https://discord.com/channels/442252698964721669/448238009733742612
62 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
63 [stackoverflow]: https://stackoverflow.com/questions/tagged/rust
64 [/r/rust]: https://www.reddit.com/r/rust
65 [discourse]: https://users.rust-lang.org