1 # Serde   [![Build Status]][travis] [![Latest Version]][crates.io] [![Rustc Version 1.13+]][rustc]
3 [Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master
4 [travis]: https://travis-ci.org/serde-rs/serde
5 [Latest Version]: https://img.shields.io/crates/v/serde.svg
6 [crates.io]: https://crates.io/crates/serde
7 [Rustc Version 1.13+]: https://img.shields.io/badge/rustc-1.13+-lightgray.svg
8 [rustc]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
10 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
14 You may be looking for:
16 - [An overview of Serde](https://serde.rs/)
17 - [Data formats supported by Serde](https://serde.rs/#data-formats)
18 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
19 - [Examples](https://serde.rs/examples.html)
20 - [API documentation](https://docs.serde.rs/serde/)
21 - [Release notes](https://github.com/serde-rs/serde/releases)
27 Click to show Cargo.toml.
28 <a href="https://play.rust-lang.org/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
34 # The core APIs, including the Serialize and Deserialize traits. Always
35 # required when using Serde.
38 # Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
39 # to work for structs and enums defined in your crate.
42 # Each data format lives in its own crate; the sample code below uses JSON
43 # but you may be using a different one.
52 extern crate serde_derive;
55 extern crate serde_json;
57 #[derive(Serialize, Deserialize, Debug)]
64 let point = Point { x: 1, y: 2 };
66 // Convert the Point to a JSON string.
67 let serialized = serde_json::to_string(&point).unwrap();
69 // Prints serialized = {"x":1,"y":2}
70 println!("serialized = {}", serialized);
72 // Convert the JSON string back to a Point.
73 let deserialized: Point = serde_json::from_str(&serialized).unwrap();
75 // Prints deserialized = Point { x: 1, y: 2 }
76 println!("deserialized = {:?}", deserialized);
82 Serde developers live in the #serde channel on [`irc.mozilla.org`][irc]. The
83 \#rust channel is also a good resource with generally faster response time but
84 less specific knowledge about Serde. If IRC is not your thing or you don't get a
85 good response, we are happy to respond to [GitHub issues][issues] as well.
87 [irc]: https://wiki.mozilla.org/IRC
88 [issues]: https://github.com/serde-rs/serde/issues/new/choose
92 Serde is licensed under either of
94 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
95 http://www.apache.org/licenses/LICENSE-2.0)
96 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
97 http://opensource.org/licenses/MIT)
103 Unless you explicitly state otherwise, any contribution intentionally submitted
104 for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
105 dual licensed as above, without any additional terms or conditions.