1 # Serde   [![Build Status]][travis] [![Latest Version]][crates.io]
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
8 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
12 You may be looking for:
14 - [An overview of Serde](https://serde.rs/)
15 - [Data formats supported by Serde](https://serde.rs/#data-formats)
16 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
17 - [Examples](https://serde.rs/examples.html)
18 - [API documentation](https://docs.serde.rs/serde/)
19 - [Release notes](https://github.com/serde-rs/serde/releases)
25 Click to show Cargo.toml.
26 <a href="http://play.integer32.com/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
32 # The core APIs, including the Serialize and Deserialize traits. Always
33 # required when using Serde.
36 # Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
37 # to work for structs and enums defined in your crate.
40 # Each data format lives in its own crate; the sample code below uses JSON
41 # but you may be using a different one.
50 extern crate serde_derive;
53 extern crate serde_json;
55 #[derive(Serialize, Deserialize, Debug)]
62 let point = Point { x: 1, y: 2 };
64 // Convert the Point to a JSON string.
65 let serialized = serde_json::to_string(&point).unwrap();
67 // Prints serialized = {"x":1,"y":2}
68 println!("serialized = {}", serialized);
70 // Convert the JSON string back to a Point.
71 let deserialized: Point = serde_json::from_str(&serialized).unwrap();
73 // Prints deserialized = Point { x: 1, y: 2 }
74 println!("deserialized = {:?}", deserialized);
80 Serde developers live in the #serde channel on
81 [`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a
82 good resource with generally faster response time but less specific knowledge
83 about Serde. If IRC is not your thing or you don't get a good response, we are
84 happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new)
89 Serde is licensed under either of
91 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
92 http://www.apache.org/licenses/LICENSE-2.0)
93 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
94 http://opensource.org/licenses/MIT)
100 Unless you explicitly state otherwise, any contribution intentionally submitted
101 for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
102 dual licensed as above, without any additional terms or conditions.