{"id":13439408,"url":"https://github.com/dtolnay/serde-yaml","last_synced_at":"2025-10-05T22:30:32.813Z","repository":{"id":39098034,"uuid":"52425435","full_name":"dtolnay/serde-yaml","owner":"dtolnay","description":"Strongly typed YAML library for Rust","archived":true,"fork":false,"pushed_at":"2024-03-25T00:50:35.000Z","size":1357,"stargazers_count":953,"open_issues_count":51,"forks_count":153,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-09-21T05:58:58.251Z","etag":null,"topics":["rust","serde","yaml"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtolnay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dtolnay"}},"created_at":"2016-02-24T08:11:01.000Z","updated_at":"2024-09-20T09:49:06.000Z","dependencies_parsed_at":"2024-06-18T13:34:25.730Z","dependency_job_id":"52717df2-6f2f-4539-bcbf-c3f94452d248","html_url":"https://github.com/dtolnay/serde-yaml","commit_stats":{"total_commits":736,"total_committers":43,"mean_commits":17.11627906976744,"dds":0.09782608695652173,"last_synced_commit":"8057faddd6bbe647d0bdae19d98087c7edced5d3"},"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fserde-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fserde-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fserde-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fserde-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtolnay","download_url":"https://codeload.github.com/dtolnay/serde-yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219864719,"owners_count":16554087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","serde","yaml"],"created_at":"2024-07-31T03:01:13.654Z","updated_at":"2025-10-05T22:30:27.439Z","avatar_url":"https://github.com/dtolnay.png","language":"Rust","funding_links":["https://github.com/sponsors/dtolnay"],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Encoding","编码 Encoding","加密 Encoding","编码(Encoding)"],"readme":"Serde YAML\n==========\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/serde--yaml-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/serde-yaml)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/serde_yaml.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/serde_yaml)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-serde__yaml-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/serde_yaml)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/serde-yaml/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/serde-yaml/actions?query=branch%3Amaster)\n\nRust library for using the [Serde] serialization framework with data in [YAML]\nfile format. _(This project is no longer maintained.)_\n\n[Serde]: https://github.com/serde-rs/serde\n[YAML]: https://yaml.org/\n\n## Dependency\n\n```toml\n[dependencies]\nserde = \"1.0\"\nserde_yaml = \"0.9\"\n```\n\nRelease notes are available under [GitHub releases].\n\n[GitHub releases]: https://github.com/dtolnay/serde-yaml/releases\n\n## Using Serde YAML\n\n[API documentation is available in rustdoc form][docs.rs] but the general idea\nis:\n\n[docs.rs]: https://docs.rs/serde_yaml\n\n```rust\nuse std::collections::BTreeMap;\n\nfn main() -\u003e Result\u003c(), serde_yaml::Error\u003e {\n    // You have some type.\n    let mut map = BTreeMap::new();\n    map.insert(\"x\".to_string(), 1.0);\n    map.insert(\"y\".to_string(), 2.0);\n\n    // Serialize it to a YAML string.\n    let yaml = serde_yaml::to_string(\u0026map)?;\n    assert_eq!(yaml, \"x: 1.0\\ny: 2.0\\n\");\n\n    // Deserialize it back to a Rust type.\n    let deserialized_map: BTreeMap\u003cString, f64\u003e = serde_yaml::from_str(\u0026yaml)?;\n    assert_eq!(map, deserialized_map);\n    Ok(())\n}\n```\n\nIt can also be used with Serde's derive macros to handle structs and enums\ndefined in your program.\n\n```toml\n[dependencies]\nserde = { version = \"1.0\", features = [\"derive\"] }\nserde_yaml = \"0.9\"\n```\n\nStructs serialize in the obvious way:\n\n```rust\nuse serde::{Serialize, Deserialize};\n\n#[derive(Debug, PartialEq, Serialize, Deserialize)]\nstruct Point {\n    x: f64,\n    y: f64,\n}\n\nfn main() -\u003e Result\u003c(), serde_yaml::Error\u003e {\n    let point = Point { x: 1.0, y: 2.0 };\n\n    let yaml = serde_yaml::to_string(\u0026point)?;\n    assert_eq!(yaml, \"x: 1.0\\ny: 2.0\\n\");\n\n    let deserialized_point: Point = serde_yaml::from_str(\u0026yaml)?;\n    assert_eq!(point, deserialized_point);\n    Ok(())\n}\n```\n\nEnums serialize using YAML's `!tag` syntax to identify the variant name.\n\n```rust\nuse serde::{Serialize, Deserialize};\n\n#[derive(Serialize, Deserialize, PartialEq, Debug)]\nenum Enum {\n    Unit,\n    Newtype(usize),\n    Tuple(usize, usize, usize),\n    Struct { x: f64, y: f64 },\n}\n\nfn main() -\u003e Result\u003c(), serde_yaml::Error\u003e {\n    let yaml = \"\n        - !Newtype 1\n        - !Tuple [0, 0, 0]\n        - !Struct {x: 1.0, y: 2.0}\n    \";\n    let values: Vec\u003cEnum\u003e = serde_yaml::from_str(yaml).unwrap();\n    assert_eq!(values[0], Enum::Newtype(1));\n    assert_eq!(values[1], Enum::Tuple(0, 0, 0));\n    assert_eq!(values[2], Enum::Struct { x: 1.0, y: 2.0 });\n\n    // The last two in YAML's block style instead:\n    let yaml = \"\n        - !Tuple\n          - 0\n          - 0\n          - 0\n        - !Struct\n          x: 1.0\n          y: 2.0\n    \";\n    let values: Vec\u003cEnum\u003e = serde_yaml::from_str(yaml).unwrap();\n    assert_eq!(values[0], Enum::Tuple(0, 0, 0));\n    assert_eq!(values[1], Enum::Struct { x: 1.0, y: 2.0 });\n\n    // Variants with no data can be written using !Tag or just the string name.\n    let yaml = \"\n        - Unit  # serialization produces this one\n        - !Unit\n    \";\n    let values: Vec\u003cEnum\u003e = serde_yaml::from_str(yaml).unwrap();\n    assert_eq!(values[0], Enum::Unit);\n    assert_eq!(values[1], Enum::Unit);\n\n    Ok(())\n}\n```\n\n\u003cbr\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fserde-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtolnay%2Fserde-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fserde-yaml/lists"}