• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!-- Serde readme rendered on crates.io -->
2
3**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
4
5---
6
7You may be looking for:
8
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)
15
16## Serde in action
17
18```rust
19use serde::{Serialize, Deserialize};
20
21#[derive(Serialize, Deserialize, Debug)]
22struct Point {
23    x: i32,
24    y: i32,
25}
26
27fn main() {
28    let point = Point { x: 1, y: 2 };
29
30    // Convert the Point to a JSON string.
31    let serialized = serde_json::to_string(&point).unwrap();
32
33    // Prints serialized = {"x":1,"y":2}
34    println!("serialized = {}", serialized);
35
36    // Convert the JSON string back to a Point.
37    let deserialized: Point = serde_json::from_str(&serialized).unwrap();
38
39    // Prints deserialized = Point { x: 1, y: 2 }
40    println!("deserialized = {:?}", deserialized);
41}
42```
43
44## Getting help
45
46Serde is one of the most widely used Rust libraries so any place that Rustaceans
47congregate will be able to help you out. For chat, consider trying the
48[#general] or [#beginners] channels of the unofficial community Discord, the
49[#rust-usage] channel of the official Rust Project Discord, or the
50[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag
51on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned
52weekly easy questions post, or the Rust [Discourse forum][discourse]. It's
53acceptable to file a support issue in this repo but they tend not to get as many
54eyes as any of the above and may get closed without a response after some time.
55
56[#general]: https://discord.com/channels/273534239310479360/274215136414400513
57[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281
58[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
59[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
60[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
61[/r/rust]: https://www.reddit.com/r/rust
62[discourse]: https://users.rust-lang.org
63