• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-14,9369,381

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

Cargo.tomlH A D01-Jan-19701.4 KiB4541

Cargo.toml.orig-cargoH A D14-Oct-20182.8 KiB8169

LICENSE-APACHEH A D14-Aug-201610.6 KiB202169

LICENSE-MITH A D14-Aug-20161 KiB2622

README.mdH A D04-Oct-20183.1 KiB10676

build.rsH A D23-Aug-20182.7 KiB9155

crates-io.mdH A D04-Oct-20181.6 KiB5739

README.md

1# Serde   [![Build Status]][travis] [![Latest Version]][crates.io] [![Rustc Version 1.13+]][rustc]
2
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
9
10**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
11
12---
13
14You may be looking for:
15
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/derive.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)
22
23## Serde in action
24
25<details>
26<summary>
27Click to show Cargo.toml.
28<a href="https://play.rust-lang.org/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">Run this code in the playground.</a>
29</summary>
30
31```toml
32[dependencies]
33
34# The core APIs, including the Serialize and Deserialize traits. Always
35# required when using Serde.
36serde = "1.0"
37
38# Support for #[derive(Serialize, Deserialize)]. Required if you want Serde
39# to work for structs and enums defined in your crate.
40serde_derive = "1.0"
41
42# Each data format lives in its own crate; the sample code below uses JSON
43# but you may be using a different one.
44serde_json = "1.0"
45```
46
47</details>
48<p></p>
49
50```rust
51#[macro_use]
52extern crate serde_derive;
53
54extern crate serde;
55extern crate serde_json;
56
57#[derive(Serialize, Deserialize, Debug)]
58struct Point {
59    x: i32,
60    y: i32,
61}
62
63fn main() {
64    let point = Point { x: 1, y: 2 };
65
66    // Convert the Point to a JSON string.
67    let serialized = serde_json::to_string(&point).unwrap();
68
69    // Prints serialized = {"x":1,"y":2}
70    println!("serialized = {}", serialized);
71
72    // Convert the JSON string back to a Point.
73    let deserialized: Point = serde_json::from_str(&serialized).unwrap();
74
75    // Prints deserialized = Point { x: 1, y: 2 }
76    println!("deserialized = {:?}", deserialized);
77}
78```
79
80## Getting help
81
82Serde 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
84less specific knowledge about Serde. If IRC is not your thing or you don't get a
85good response, we are happy to respond to [GitHub issues][issues] as well.
86
87[irc]: https://wiki.mozilla.org/IRC
88[issues]: https://github.com/serde-rs/serde/issues/new/choose
89
90## License
91
92Serde is licensed under either of
93
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)
98
99at your option.
100
101### Contribution
102
103Unless you explicitly state otherwise, any contribution intentionally submitted
104for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
105dual licensed as above, without any additional terms or conditions.
106